arduino-audio-tools
|
Very Simple Buffer implementation for Pitch Shift. More...
#include <PitchShift.h>
Public Member Functions | |
VariableSpeedRingBufferSimple (int size=0, float increment=1.0) | |
Constructor. | |
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) |
Peek at the current sample without advancing the read pointer. | |
bool | read (T &result) |
Read the next sample and advance the read pointer. | |
virtual int | readArray (T data[], int len) |
reads multiple values | |
void | reset () |
Reset pointer positions and clear buffer. | |
bool | resize (int size) |
Resize the internal buffer. | |
void | setIncrement (float increment) |
Set the reading speed increment. | |
size_t | size () |
bool | write (T sample) |
Write a sample 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 Attributes | |
Vector< T > | buffer {0} |
int | buffer_size = 0 |
float | read_increment = 1.0 |
float | read_pos_float = 0.0 |
int | write_pos = 0 |
Very Simple Buffer implementation for Pitch Shift.
This buffer writes samples at constant speed but allows reading at variable speed to achieve pitch shifting. The reading speed is controlled by the increment parameter. When read and write pointers overlap, some audio artifacts (noise) may be audible.
T | The sample data type (typically int16_t or float) |
|
inline |
Constructor.
size | Initial buffer size (0 means no allocation yet) |
increment | Reading speed multiplier (1.0 = normal speed, >1.0 = faster reading for higher pitch) |
|
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< float >, SingleBuffer< int16_t >, SingleBuffer< stsz_sample_size_t >, SingleBuffer< uint32_t >, and SingleBuffer< uint8_t >.
|
inlinevirtual |
checks if the buffer is full
Reimplemented from BaseBuffer< T >.
|
inlinevirtual |
Peek at the current sample without advancing the read pointer.
result | Reference to store the sample value |
Implements BaseBuffer< T >.
|
inlinevirtual |
Read the next sample and advance the read pointer.
result | Reference to store the read sample value |
Read the next sample and advance the read pointer
result | Reference to store the read sample value |
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
reads multiple values
Reimplemented in RingBufferFile< File, T >, BufferRTOS< T >, SynchronizedBuffer< T >, RedisBuffer< T >, BufferRP2040T< T >, NBufferFile< File, T >, and DynamicMultiBuffer< T, BufferType >.
|
inlinevirtual |
Reset pointer positions and clear buffer.
Implements BaseBuffer< T >.
|
inlinevirtual |
Resize the internal buffer.
size | New buffer size in samples |
Reimplemented from BaseBuffer< T >.
|
inline |
Set the reading speed increment.
increment | Reading speed multiplier (1.0 = normal, >1.0 = faster for higher pitch) |
|
inlinevirtual |
Implements BaseBuffer< T >.
|
inlinevirtual |
Write a sample to the buffer.
sample | The sample value to write |
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Fills the buffer data.
Reimplemented in BufferRTOS< T >, SynchronizedBuffer< T >, RedisBuffer< T >, BufferRP2040T< T >, SingleBuffer< T >, RingBufferFile< File, T >, NBufferFile< File, T >, and DynamicMultiBuffer< T, BufferType >.