-
-
Notifications
You must be signed in to change notification settings - Fork 242
Performance
The framework is supporting quite a few scenarios. The default settings have been chosen to work well in avarage with most of the scenarios. You have quite a few options to tweak the performance for your individual case. A good starting point are the settings in the AudioConfig.h. You either can change the values directly in the AudioConfig.h or create a local AudioConfigLocal.h file. The most relevant settings are
- DEFAULT_BUFFER_SIZE
- I2S_BUFFER_SIZE
- I2S_BUFFER_COUNT
Please note that increasing the values might improve if the audio is breaking up. Reducing the values is reducing the delays!
The i2s buffer definition can also be changed programmatically in your sketch when you define your i2s configuration with the help of the buffer_count and buffer_size attributes. (Please note, the available configuration attributes are platform specific: e.g. for the actual ESP32)
Since changing any values in the AudioConfig is affecting all your sketches, I generally recommend to update the values in the stream dependent configuration settings via the API.
If you have activated logging please note the following: A log level of Info or below is leading to a poor audio quality or that the audio is breaking up. So after your sketch is working do not forget to set the Log level to Warning or Error!
When you define the StreamCopy you can specify the buffer size in the constructor
StreamCopy(Print &to, Stream &from, int buffer_size=DEFAULT_BUFFER_SIZE);
When you define the AudioSourceSdFat you can define the SPI speed in MHz in the constructor:
AudioSourceSdFat(const char* startFilePath = "/", const char* ext = ".mp3", int chipSelect = PIN_CS, int speedMHz = 2);
The URLStream is usually fast enough to stream audio data. Make sure that you have a good wifi and network connection. To optimize the settings you can try to play around with the copy buffer size which is provided in the constructor and the I2S Buffers.
On platforms that support FreeRTOS you can also use a buffered URL implementation: The URLStreamBuffered uses it's own task and buffer to store the received (encoded) data which is defined by
- DEFAULT_BUFFER_SIZE,
- URL_STREAM_BUFFER_COUNT
The following parameters are also relevant:
#define URL_STREAM_CORE 0
#define URL_STREAM_PRIORITY 2
#define STACK_SIZE 30000
#define URL_CLIENT_TIMEOUT 60000;
#define URL_HANDSHAKE_TIMEOUT 120000