|
| | VariableSpeedRingBuffer180 (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 operation not supported in this buffer implementation.
|
| |
| bool | read (T &result) |
| | Read the next pitch-shifted sample.
|
| |
| 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 and recalculate overlap region.
|
| |
| void | setIncrement (float increment) |
| | Set the pitch shift factor.
|
| |
| 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.
|
| |
template<typename T = int16_t>
class audio_tools::VariableSpeedRingBuffer180< T >
Variable speed ring buffer with 180-degree phase shifting.
Advanced buffer implementation that reads with 0° and 180° phase offsets and blends the results to prevent overrun artifacts. This technique reduces audio artifacts when read and write pointers collide by cross-fading between two read positions that are 180° apart (half buffer apart).
Based on the algorithm described at: https://github.com/YetAnotherElectronicsChannel/STM32_DSP_PitchShift
- Template Parameters
-
| T | The sample data type (typically int16_t or float) |
template<typename T = int16_t>
Core pitch shifting algorithm with 180° phase offset blending.
This method implements the heart of the pitch shifting algorithm:
- Creates two read pointers: one at current position, one 180° (half-buffer) away
- Reads samples from both positions
- Detects when read pointers approach the write pointer
- Cross-fades between the two samples to prevent artifacts
- Advances the read position by the pitch_shift factor
The 180° offset ensures that when one read pointer collides with the write pointer, the other is safely away, allowing smooth transition.
- Returns
- Pitch-shifted sample with cross-fading applied