|
arduino-audio-tools
|
Real-time pitch shifting audio effect. More...
#include <PitchShift.h>
Public Member Functions | |
| PitchShiftOutput (Print &out) | |
| Constructor. | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| virtual int | availableForWrite () override |
| bool | begin () |
| Initialize pitch shifting with current configuration. | |
| virtual bool | begin (AudioInfo info) |
| bool | begin (PitchShiftInfo info) |
| Initialize pitch shifting with configuration. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| PitchShiftInfo | defaultConfig () |
| Get default configuration for pitch shifting. | |
| void | end () |
| Stop pitch shifting and deactivate the effect. | |
| virtual void | flush () |
| virtual bool | isDeletable () |
| If true we need to release the related memory in the destructor. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| virtual | operator bool () |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| virtual void | setAudioInfo (AudioInfo newInfo) override |
| Defines the input AudioInfo. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| size_t | write (const uint8_t *data, size_t len) override |
| Process and write audio data with pitch shifting applied. | |
| virtual size_t | write (uint8_t ch) override |
| virtual void | writeSilence (size_t len) |
Protected Member Functions | |
| void | notifyAudioChange (AudioInfo info) |
| T | pitchShift (T value) |
| Execute pitch shift on a single sample. | |
Protected Attributes | |
| int | _timeout = 10 |
| bool | active = false |
| Whether pitch shifting is currently active. | |
| BufferT | buffer |
| Variable speed buffer for pitch shifting. | |
| PitchShiftInfo | cfg |
| Current configuration. | |
| bool | is_active = false |
| bool | is_notify_active = true |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_out = nullptr |
| Output stream for processed audio. | |
| SingleBuffer< uint8_t > | tmp {MAX_SINGLE_CHARS} |
| int | tmpPos = 0 |
Real-time pitch shifting audio effect.
This class implements real-time pitch shifting that changes the frequency of audio without affecting its duration. It can shift pitch up or down while maintaining the original playback speed. The implementation:
The pitch shifting is accomplished using a variable-speed ring buffer that reads at different rates than it writes. Three buffer implementations are available:
| T | Sample data type (int16_t, int32_t, float, etc.) |
| BufferT | Buffer implementation type (one of the VariableSpeedRingBuffer variants) |
Constructor.
| out | Reference to the output stream where processed audio will be written |
|
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 AdapterPrintToAudioOutput, EncodedAudioOutput, and AdapterAudioStreamToAudioOutput.
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
Reimplemented from Print.
Reimplemented in AudioESP32ULP, RTSPOutput< Platform >, EncodedAudioOutput, AudioServerEx, AudioSyncWriter, AdapterAudioStreamToAudioOutput, CsvOutput< T >, MemoryOutput, and PWMAudioOutput.
Initialize pitch shifting with current configuration.
Reimplemented from AudioOutput.
Reimplemented in AudioESP32ULP, RTSPOutput< Platform >, RTTTLOutput< T >, ChannelsSelectOutput, CsvOutput< T >, and EncodedAudioOutput.
Initialize pitch shifting with configuration.
| info | Configuration containing pitch_shift factor, buffer_size, and audio format |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inline |
Get default configuration for pitch shifting.
Stop pitch shifting and deactivate the effect.
Reimplemented from AudioOutput.
Reimplemented from Print.
Reimplemented in MultiOutput, and HexDumpOutput.
If true we need to release the related memory in the destructor.
Reimplemented in AdapterPrintToAudioOutput, and AdapterAudioStreamToAudioOutput.
Reimplemented in RTSPOutput< Platform >, EncodedAudioOutput, and AdapterAudioStreamToAudioOutput.
Execute pitch shift on a single sample.
This method performs the core pitch shifting operation by writing the input sample to the buffer and reading back the pitch-shifted result. The time difference between write and read operations, controlled by the buffer's increment factor, creates the pitch shift effect.
| value | Input sample value |
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in ChannelsSelectOutput, AdapterPrintToAudioOutput, MultiOutput, AdapterAudioStreamToAudioOutput, CsvOutput< T >, PWMAudioOutput, and EncodedAudioOutput.
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
Process and write audio data with pitch shifting applied.
This method processes the input audio by:
| data | Pointer to input audio data |
| len | Number of bytes to process |
Implements AudioOutput.
Reimplemented in MetaDataOutput, and MultiOutput.
Writes n 0 values (= silence)
| len |
|
protectedinherited |
Whether pitch shifting is currently active.
Variable speed buffer for pitch shifting.
|
protected |
Current configuration.
|
protectedinherited |
Output stream for processed audio.
|
protectedinherited |
|
protectedinherited |