template<size_t workspace_bytes>
class daisy::WavPlayer< workspace_bytes >
WAV file Streaming Playback
At this time, this class only supports streaming of 16-bit WAV Files The output of this class will be in float converted from 16-bit integers and linearly interpolated for non-integer playback speeds.
Due to the implementation, reverse playback is not possible with this class.
The workspace_bytes template parameter is used to set the size in bytes of audio samples within the FIFO.
The bulk of amount of memory used by this class is approximately: (2 * workspace_bytes); This could hypothetically be reduced by half by directly accessing the FIFO's inner array (requires modifications to FIFO class), or making a new type of queue data structure
Whenever the Stream function results in a the samples FIFO being less than 75% full, it will generate a request for new data. So the average disk i/o transaction will be the workspace_bytes
/ 4. However, There are times, like when restarting playback, or opening a different file, that will trigger the entire buffer to be filled.
template<size_t workspace_bytes>
Stream Audio from disk at the current playback speed.
Each call to this will increment the playback position's internal accumulator by the playback speed. Anytime this accumulator exceeds 1.0, it will update it's position tracker, and pop the next sample from the FIFO of audio samples. Whenever the contents of the audio sample FIFO fall below 75% of it's capacity, a request is generated to refill it. The maximum playback speed possible is limited to the following factors:
- SD Card Bus-width
- SD Card Clock Speed
- workspace_bytes setting (consequently, transfer sizes)
It is possible to allow higher playback speeds, and improve bandwidth by using higher workspace sizes, with the trade-offs being memory, and latency with certain transactions.
- Parameters
-
samples | buffer of floats to fill with audio samples from disk |
num_channels | number of channels provided to fill. This can be different from the number of channels in the file. |