ASPiK SDK
PhaseVocoder Class Reference

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
 

Detailed Description

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:

  • processes mono input into mono output.

Control I/F:

  • none.
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included in Designing Audio Effects Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2018 / 09 / 7

Member Function Documentation

◆ addZeroPad()

bool PhaseVocoder::addZeroPad ( unsigned int  count)

zero pad the input timeline

add zero-padding without advancing output read location, for fast convolution

  • NOTES:
Parameters
countthe number of zero-valued samples to insert
Returns
true if the zero-insertion triggered a FFT event, false otherwise

◆ advanceAndCheckFFT()

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

  • NOTES:
Returns
true if the advancement triggered a FFT event, false otherwise

◆ destroyFFTW()

void PhaseVocoder::destroyFFTW ( )

destroys the FFTW arrays and plans.

destroy FFTW objects and plans

◆ doInverseFFT()

void PhaseVocoder::doInverseFFT ( )

perform the inverse FFT on the processed data

do the inverse FFT (optional; will be called automatically if not used)

  • NOTES:
    This function is optional - if you need to sequence the output (synthesis) stage yourself
    then you can call this function at the appropriate time - see the PSMVocoder object for an example

◆ doOverlapAdd()

void PhaseVocoder::doOverlapAdd ( double *  outputData = nullptr,
int  length = 0 
)

perform the overlap/add on the IFFT data

do the overlap-add operation

  • NOTES:
    This function is optional - if you need to sequence the output (synthesis) stage yourself
    then you can call this function at the appropriate time - see the PSMVocoder object for an example
Parameters
outputDataan array of data to overlap/add: if this is NULL then the IFFT data is used
lengththe lenght of the array of data to overlap/add: if this is -1, the normal IFFT length is used

◆ getFFTData()

fftw_complex* PhaseVocoder::getFFTData ( )
inline

get FFT data for manipulation (yes, naked pointer so you can manipulate)

◆ getFrameLength()

unsigned int PhaseVocoder::getFrameLength ( )
inline

get current FFT length

◆ getHopSize()

unsigned int PhaseVocoder::getHopSize ( )
inline

get current hop size ha = hs

◆ getIFFTData()

fftw_complex* PhaseVocoder::getIFFTData ( )
inline

get IFFT data for manipulation (yes, naked pointer so you can manipulate)

◆ getOverlap()

double PhaseVocoder::getOverlap ( )
inline

get current overlap as a raw value (75% = 0.75)

◆ initialize()

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

  • NOTES:
    See notes on symmetrical window arrays in comments.
Parameters
_frameLengththe FFT length - MUST be a power of 2
_hopSizethe hop size in samples: this object only supports ha = hs (pure real-time operation only)
_windowthe window type (note: may be set to windowType::kNoWindow)

◆ processAudioSample()

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

  • NOTES:
Parameters
inputthe input sample x(n)
fftReadya return flag indicating if the FFT has occurred and FFT data is ready to process
Returns
the vocoder output sample y(n)

◆ setOverlapAddOnly()

void PhaseVocoder::setOverlapAddOnly ( bool  b)
inline

set the vocoder for overlap add only without hop-size


The documentation for this class was generated from the following files: