|
arduino-audio-tools
|
Dynamic Resampling. We can use a variable factor to speed up or slow down the playback. More...
#include <ResampleStream.h>
Public Member Functions | |
| ResampleStream ()=default | |
| ResampleStream (AudioOutput &out) | |
| ResampleStream (AudioStream &io) | |
| ResampleStream (Print &out) | |
| Support for resampling via write. | |
| ResampleStream (Stream &io) | |
| Support for resampling via write and read. | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| AudioInfo | audioInfoOut () override |
| int | available () override |
| int | availableForWrite () override |
| bool | begin () override |
| bool | begin (AudioInfo from, AudioInfo to) |
| bool | begin (AudioInfo from, int toRate) |
| bool | begin (AudioInfo from, sample_rate_t toRate) |
| virtual bool | begin (AudioInfo info) |
| bool | begin (AudioInfo info, float step) |
| bool | begin (ResampleConfig cfg) |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| ResampleConfig | defaultConfig () |
| Provides the default configuraiton. | |
| void | end () override |
| void | flush () |
| When buffering is active, writes the buffered audio to the output. | |
| float | getByteFactor () override |
| virtual Print * | getPrint () |
| float | getStepSize () |
| Returns the actual step size. | |
| float | getStepSize (float sampleRateFrom, float sampleRateTo) |
| virtual Stream * | getStream () |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| virtual | operator bool () |
| size_t | readBytes (uint8_t *data, size_t len) override |
| virtual size_t | readSilence (uint8_t *buffer, size_t length) |
| Source to generate silence: just sets the buffer to 0. | |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| void | resizeReadResultQueue (int size) |
| void | setAudioInfo (AudioInfo newInfo) override |
| Defines the input AudioInfo. | |
| void | setBuffered (bool active) |
| Activates buffering to avoid small incremental writes. | |
| void | setMaxReadSize (int size) |
| Defines the read buffer size for individual reads: same as transformationReader().setMaxReadSize(size) | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| virtual void | setOutput (AudioOutput &print) |
| Defines/Changes the output target and registers for audio change notifications. | |
| virtual void | setOutput (Print &print) override |
| Defines/Changes the output target. | |
| void | setReadResultQueueSize (int size) |
| same as resizeReadResultQueue(size) | |
| void | setStepSize (float step) |
| influence the sample rate | |
| virtual void | setStream (AudioStream &stream) |
| Defines/Changes the input & output and registers for audio change notifications. | |
| virtual void | setStream (Stream &stream) override |
| Defines/Changes the input & output. | |
| void | setTargetSampleRate (int rate) |
| void | setWriteBufferSize (int size) |
| virtual TransformationReader< ReformatBaseStream > & | transformationReader () |
| Provides access to the TransformationReader. | |
| size_t | write (const uint8_t *data, size_t len) override |
| virtual size_t | write (uint8_t ch) override |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
Protected Member Functions | |
| template<typename T > | |
| T | getValue (T *data, float frame_idx, int channel) |
| get the interpolated value for indicated (float) index value | |
| template<typename T > | |
| T | lookup (T *data, int frame, int channel) |
| lookup value for indicated frame & channel: index starts with -1; | |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| void | setupLastSamples (AudioInfo cfg) |
| Sets up the buffer for the rollover samples. | |
| template<typename T > | |
| void | setupLastSamples (T *data, int frame) |
| store last samples to provide values for index -1 | |
| void | setupReader () |
| template<typename T > | |
| size_t | write (Print *p_out, const uint8_t *buffer, size_t bytes, size_t &written) |
| Writes the buffer to defined output after resampling. | |
Protected Attributes | |
| int | _timeout = 10 |
| int | bytes_per_frame = 0 |
| float | idx = 0 |
| AudioInfo | info |
| bool | is_buffer_active = USE_RESAMPLE_BUFFER |
| bool | is_first = true |
| bool | is_notify_active = true |
| Vector< uint8_t > | last_samples {0} |
| Vector< AudioInfoSupport * > | notify_vector |
| SingleBuffer< uint8_t > | out_buffer {0} |
| Print * | p_out = nullptr |
| Print * | p_print = nullptr |
| Stream * | p_stream = nullptr |
| TransformationReader< ReformatBaseStream > | reader |
| float | step_size = 1.0 |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| int | to_sample_rate = 0 |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Dynamic Resampling. We can use a variable factor to speed up or slow down the playback.
| T |
|
default |
|
inline |
Support for resampling via write.
|
inline |
Support for resampling via write. The audio information is copied from the io
|
inline |
Support for resampling via write and read.
|
inline |
Support for resampling via write and read. The audio information is copied from the io
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
|
inlineoverridevirtual |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented from AudioInfoSupport.
|
inlineoverridevirtualinherited |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Reimplemented from BaseStream.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inline |
|
inline |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inline |
Provides the default configuraiton.
|
inlineoverridevirtualinherited |
Reimplemented from BaseStream.
|
inlinevirtual |
When buffering is active, writes the buffered audio to the output.
Reimplemented from ReformatBaseStream.
|
inlineoverridevirtual |
Implements ReformatBaseStream.
|
inline |
Returns the actual step size.
calculate the step size the sample rate: e.g. from 44200 to 22100 gives a step size of 2 in order to provide fewer samples
get the interpolated value for indicated (float) index value
lookup value for indicated frame & channel: index starts with -1;
Reimplemented from AudioStream.
Source to generate silence: just sets the buffer to 0.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
Define the size of the interal read result queue: same as transformationReader().resizeResultQueue(size)
Defines the input AudioInfo.
Reimplemented from AudioStream.
Defines the read buffer size for individual reads: same as transformationReader().setMaxReadSize(size)
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlinevirtualinherited |
Defines/Changes the output target and registers for audio change notifications.
Reimplemented from ModifyingStream.
Reimplemented in FormatConverterStream, and EncodedAudioStream.
Defines/Changes the output target.
Implements ModifyingStream.
Reimplemented in EncodedAudioStream, and FormatConverterStream.
|
inlinevirtualinherited |
Defines/Changes the input & output and registers for audio change notifications.
Reimplemented from ModifyingStream.
Reimplemented in FormatConverterStream, and EncodedAudioStream.
Defines/Changes the input & output.
Implements ModifyingStream.
Reimplemented in FormatConverterStream, and EncodedAudioStream.
store last samples to provide values for index -1
|
inlineprotectedinherited |
|
inlinevirtualinherited |
Provides access to the TransformationReader.
Reimplemented from AudioStream.
|
inlineprotected |
Writes the buffer to defined output after resampling.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |