arduino-audio-tools
|
Optimized Buffer implementation for Pitch Shift. We try to interpolate the samples and restore the phase when the read pointer and write pointer overtake each other. More...
#include <PitchShift.h>
Public Member Functions | |
VariableSpeedRingBuffer (int size=0, float increment=1.0) | |
virtual T * | address () |
returns the address of the start of the physical read buffer | |
virtual int | available () |
provides the number of entries that are available to read | |
virtual int | availableForWrite () |
provides the number of entries that are available to write | |
void | clear () |
same as reset | |
virtual int | clearArray (int len) |
Removes the next len entries. | |
bool | isEmpty () |
virtual bool | isFull () |
checks if the buffer is full | |
virtual float | levelPercent () |
Returns the level of the buffer in %. | |
bool | peek (T &result) |
peeks the actual entry from the buffer | |
bool | read (T &result) |
reads a single value | |
virtual int | readArray (T data[], int len) |
reads multiple values | |
void | reset () |
Reset pointer positions and clear buffer. | |
void | resize (int size) |
void | setIncrement (float increment) |
size_t | size () |
bool | write (T sample) |
write add an entry to the buffer | |
virtual int | writeArray (const T data[], int len) |
Fills the buffer data. | |
virtual int | writeArrayOverwrite (const T data[], int len) |
Fills the buffer data and overwrites the oldest data if the buffer is full. | |
Protected Member Functions | |
T | getValue (int pos) |
provides the value from the buffer: Allows pos > buffer_size | |
void | handleReadWriteOverrun (T last_value) |
T | interpolate (float read_pos) |
Calculate exact sample value for float position. | |
bool | isMatching (T value1, bool incrementing, T v1, T v2) |
void | setWritePos (int pos) |
Protected Attributes | |
Vector< T > | buffer {0} |
int | buffer_size |
bool | incrementing |
T | last_value = 0 |
friend | NBuffer< T > |
float | read_increment = 0.0f |
float | read_pos_float = 0.0f |
int | write_pos = 0 |
Optimized Buffer implementation for Pitch Shift. We try to interpolate the samples and restore the phase when the read pointer and write pointer overtake each other.
T |
|
inlinevirtual |
returns the address of the start of the physical read buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
provides the number of entries that are available to read
Implements BaseBuffer< T >.
|
inlinevirtual |
provides the number of entries that are available to write
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Removes the next len entries.
Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.
|
inlineprotected |
When the read pointer is overpassing the write pointer or the write pointer is overpassing the read pointer we need to phase shift
|
inlinevirtual |
checks if the buffer is full
Reimplemented from BaseBuffer< T >.
|
inlineprotected |
checks if we can fit the last value between 2 existing values in the buffer
|
inlinevirtual |
peeks the actual entry from the buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
reads a single value
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
reads multiple values
Reimplemented in RingBufferFile< File, T >, BufferRTOS< T >, SynchronizedBuffer< T >, BufferRP2040T< T >, and NBufferFile< File, T >.
|
inlinevirtual |
Reset pointer positions and clear buffer.
Implements BaseBuffer< T >.
|
inlinevirtual |
Implements BaseBuffer< T >.
|
inlinevirtual |
write add an entry to the buffer
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Fills the buffer data.
Reimplemented in BufferRTOS< T >, SynchronizedBuffer< T >, BufferRP2040T< T >, RingBufferFile< File, T >, and NBufferFile< File, T >.