Skip to content

Commit 693e000

Browse files
Psram buffer (#14)
This PR adds a ringbuffer on boards that have psram. Without psram the stream will be played straight from the HTTPClient stream buffer as before. To override this behaviour -and have no ringbuffer- set 'VS1053_PSRAM_BUFFER' to 'false'.
1 parent 2dbc95d commit 693e000

File tree

3 files changed

+273
-49
lines changed

3 files changed

+273
-49
lines changed

README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7571166c872e4dc8a899382389b73f8e)](https://app.codacy.com/gh/CelliesProjects/ESP32_VS1053_Stream?utm_source=github.com&utm_medium=referral&utm_content=CelliesProjects/ESP32_VS1053_Stream&utm_campaign=Badge_Grade_Settings)
44

55
A streaming library for esp32 with a separate VS1053 mp3/ogg/aac/flac/wav decoder.
6-
This library plays mp3, ogg, aac, aac+ and flac files and streams. Supports http, https (insecure mode) and chunked audio streams.
6+
This library plays mp3, ogg, aac, aac+ and <strike>flac</strike> files and streams. Supports http, https (insecure mode) and chunked audio streams.
7+
8+
If there is psram found then a 32kB ringbuffer will be allocated and used, otherwise the stream will be played straight from the HTTPClient stream buffer.
79

810
This library needs [ESP_VS1053_Library](https://github.com/baldram/ESP_VS1053_Library) to communicate with the decoder.
911

@@ -76,17 +78,20 @@ void audio_eof_stream(const char* info) {
7678
}
7779
```
7880
79-
## Functions
81+
# Functions
8082
8183
### Initialize the VS1053 codec
8284
```c++
8385
bool startDecoder(CS, DCS, DREQ)
8486
```
87+
<hr>
8588

8689
### Check if VS1053 is responding
8790
```c++
8891
bool isChipConnected()
8992
```
93+
<hr>
94+
9095

9196
### Start or resume a stream
9297
```c++
@@ -101,32 +106,44 @@ bool connecttohost(url, user, pwd)
101106
```c++
102107
bool connecttohost(url, user, pwd, offset)
103108
```
109+
<hr>
110+
104111
### Stop a stream
105112
```c++
106113
void stopSong()
107114
```
115+
<hr>
116+
108117

109118
### Feed the decoder
110119
```c++
111120
void loop()
112121
```
113122
This function has to called every couple of ms to feed the decoder with data. For bitrates up to 320kbps once every 25 ms is about right.
123+
<hr>
124+
114125

115126
### Check if stream is running
116127
```c++
117128
bool isRunning()
118129
```
130+
<hr>
131+
119132

120133
### Get the current volume
121134
```c++
122135
uint8_t getVolume()
123136
```
137+
<hr>
138+
124139

125140
### Set the volume
126141
```c++
127142
void setVolume(uint8_t volume)
128143
```
129144
Value should be between 0-100.
145+
<hr>
146+
130147
131148
### Set bass and treble
132149
```c++
@@ -141,46 +158,56 @@ tonehf = <0..15> // Setting treble frequency lower limit x 1000 Hz
141158
tonela = <0..15> // Setting bass gain (0 = off, 1dB steps)
142159
tonelf = <0..15> // Setting bass frequency lower limit x 10 Hz
143160
```
161+
<hr>
162+
144163

145164
### Get the current used codec
146165
```c++
147166
const char* currentCodec()
148167
```
149168
Returns `STOPPED` if no stream is running.
169+
<hr>
150170

151171
### Get the current stream url
152172
```c++
153173
const char* lastUrl()
154174
```
155175
The current stream url might differ from the request url if the request url points to a playlist.
176+
<hr>
156177

157178
### Get the filesize
158179
```c++
159180
size_t size()
160181
```
161182
Returns `0` if the stream is a radio stream.
183+
<hr>
162184

163185
### Get the current position in the file
164186
```c++
165187
size_t position()
166188
```
167189
Returns `0` if the stream is a radio stream.
190+
<hr>
168191

169-
## Event callbacks
192+
# Event callbacks
193+
### Station name callback.
170194
```c++
171195
void audio_showstation(const char* info)
172196
```
173-
Returns the station name.
197+
<hr>
174198
199+
### Stream information callback.
175200
```c++
176201
void audio_showstreamtitle(const char* info)
177202
```
178-
Returns ICY stream information.
203+
<hr>
179204

205+
### End of file callback.
180206
```c++
181207
void audio_eof_stream(const char* info)
182208
```
183-
Is called when the current stream reaches the end of file. Returns the current url.
209+
Returns the current url. Very handy for coding a playlist.
210+
<hr>
184211
185212
## License
186213

0 commit comments

Comments
 (0)