ASPiK SDK
|
The PhaseVocoder provides a basic phase vocoder that is initialized to N = 4096 and 75% overlap; the de-facto standard for PSM algorithms. The analysis and sythesis hop sizes are identical. More...
#include <fxobjects.h>
Public Member Functions | |
void | initialize (unsigned int _frameLength, unsigned int _hopSize, windowType _window) |
initialize the Fast FFT object for operation More... | |
void | destroyFFTW () |
destroys the FFTW arrays and plans. More... | |
double | processAudioSample (double input, bool &fftReady) |
process one input sample throug the vocoder to produce one output sample More... | |
bool | addZeroPad (unsigned int count) |
zero pad the input timeline More... | |
bool | advanceAndCheckFFT () |
advance the sample counter and check to see if we need to do the FFT. More... | |
fftw_complex * | getFFTData () |
fftw_complex * | getIFFTData () |
void | doInverseFFT () |
perform the inverse FFT on the processed data More... | |
void | doOverlapAdd (double *outputData=nullptr, int length=0) |
perform the overlap/add on the IFFT data More... | |
unsigned int | getFrameLength () |
unsigned int | getHopSize () |
double | getOverlap () |
void | setOverlapAddOnly (bool b) |
Protected Attributes | |
fftw_complex * | fft_input = nullptr |
array for FFT input | |
fftw_complex * | fft_result = nullptr |
array for FFT output | |
fftw_complex * | ifft_result = nullptr |
array for IFFT output | |
fftw_plan | plan_forward = nullptr |
FFTW plan for FFT. | |
fftw_plan | plan_backward = nullptr |
FFTW plan for IFFT. | |
double * | windowBuffer = nullptr |
array for window | |
double * | inputBuffer = nullptr |
input timeline (x) | |
double * | outputBuffer = nullptr |
output timeline (y) | |
unsigned int | inputWriteIndex = 0 |
circular buffer index: input write | |
unsigned int | outputWriteIndex = 0 |
circular buffer index: output write | |
unsigned int | inputReadIndex = 0 |
circular buffer index: input read | |
unsigned int | outputReadIndex = 0 |
circular buffer index: output read | |
unsigned int | wrapMask = 0 |
input wrap mask | |
unsigned int | wrapMaskOut = 0 |
output wrap mask | |
double | windowHopCorrection = 1.0 |
window correction including hop/overlap | |
bool | needInverseFFT = false |
internal flag to signal IFFT required | |
bool | needOverlapAdd = false |
internal flag to signal overlap/add required | |
windowType | window = windowType::kHannWindow |
window type | |
unsigned int | frameLength = 0 |
current FFT length | |
unsigned int | fftCounter = 0 |
FFT sample counter. | |
unsigned int | hopSize = 0 |
hop: ha = hs | |
double | overlap = 1.0 |
overlap as raw value (75% = 0.75) | |
bool | overlapAddOnly = false |
flag for overlap-add-only algorithms | |
The PhaseVocoder provides a basic phase vocoder that is initialized to N = 4096 and 75% overlap; the de-facto standard for PSM algorithms. The analysis and sythesis hop sizes are identical.
Audio I/O:
Control I/F:
bool PhaseVocoder::addZeroPad | ( | unsigned int | count | ) |
zero pad the input timeline
add zero-padding without advancing output read location, for fast convolution
count | the number of zero-valued samples to insert |
bool PhaseVocoder::advanceAndCheckFFT | ( | ) |
advance the sample counter and check to see if we need to do the FFT.
increment the FFT counter and do the FFT if it is ready
void PhaseVocoder::destroyFFTW | ( | ) |
destroys the FFTW arrays and plans.
destroy FFTW objects and plans
void PhaseVocoder::doInverseFFT | ( | ) |
perform the inverse FFT on the processed data
do the inverse FFT (optional; will be called automatically if not used)
void PhaseVocoder::doOverlapAdd | ( | double * | outputData = nullptr , |
int | length = 0 |
||
) |
perform the overlap/add on the IFFT data
do the overlap-add operation
outputData | an array of data to overlap/add: if this is NULL then the IFFT data is used |
length | the lenght of the array of data to overlap/add: if this is -1, the normal IFFT length is used |
|
inline |
get FFT data for manipulation (yes, naked pointer so you can manipulate)
|
inline |
get current FFT length
|
inline |
get current hop size ha = hs
|
inline |
get IFFT data for manipulation (yes, naked pointer so you can manipulate)
|
inline |
get current overlap as a raw value (75% = 0.75)
void PhaseVocoder::initialize | ( | unsigned int | _frameLength, |
unsigned int | _hopSize, | ||
windowType | _window | ||
) |
initialize the Fast FFT object for operation
setup the FFT for a given framelength and window type
_frameLength | the FFT length - MUST be a power of 2 |
_hopSize | the hop size in samples: this object only supports ha = hs (pure real-time operation only) |
_window | the window type (note: may be set to windowType::kNoWindow) |
double PhaseVocoder::processAudioSample | ( | double | input, |
bool & | fftReady | ||
) |
process one input sample throug the vocoder to produce one output sample
process audio sample through vocode; check fftReady flag to access FFT output
input | the input sample x(n) |
fftReady | a return flag indicating if the FFT has occurred and FFT data is ready to process |
|
inline |
set the vocoder for overlap add only without hop-size