Extended

Oscillators

class maxiPolyBLEP

Anti-aliased oscillators;

Public Types

using Waveform = PolyBLEP::Waveform

Waveform types: SINE, COSINE, TRIANGLE, SQUARE, RECTANGLE, SAWTOOTH, RAMP, MODIFIED_TRIANGLE, MODIFIED_SQUARE, HALF_WAVE_RECTIFIED_SINE, FULL_WAVE_RECTIFIED_SINE, TRIANGULAR_PULSE, TRAPEZOID_FIXED, TRAPEZOID_VARIABLE

Public Functions

inline maxiPolyBLEP()

Constructor

inline double play(double freq)

play the oscillator

Parameters

freq – frequency in Hz

inline void setWaveform(Waveform waveform)

Set the waveform type

inline void setPulseWidth(double pw)

Change the pulse width (0 <= pw <= 1)

Spectral Analysis and Processing

class maxiFFT

Fast fourier transform. For spectral audio process and machine listening.

Subclassed by maxiFFTAdaptor

Public Types

enum fftModes

How to run the FFT - with or without polar conversion

Values:

enumerator NO_POLAR_CONVERSION
enumerator WITH_POLAR_CONVERSION

Public Functions

void setup(int fftSize = 1024, int hopSize = 512, int windowSize = 0)

Configure the FFT.

Parameters
  • fftSize – the FFT size. This must be a power of 2

  • hopSize – the hop size

  • windowSize – the window size

bool process(float value, fftModes mode = maxiFFT::WITH_POLAR_CONVERSION)

Analyse an audio signal with FFT

Parameters
  • value – a signal

  • mode – see fftModes enumeration

Returns

true when the analysis has run (every [hopsize] samples)

inline float *getReal()
Returns

a pointer to an array of values containing the real components of the fft analysis

inline float *getImag()
Returns

a pointer to an array of values containing the imaginary components of the fft analysis

inline std::vector<float> &getMagnitudes()
Returns

a vector of magnitudes (assuming the FFT was calcuated with polar conversion)

inline std::vector<float> &getMagnitudesDB()
Returns

a vector of magnitudes in decibels (assuming the FFT was calcuated with polar conversion)

inline std::vector<float> &getPhases()
Returns

a vector of phases (assuming the FFT was calcuated with polar conversion)

inline int getNumBins()
Returns

the number of bins in the FFT analysis

inline int getFFTSize()
Returns

the FFT size

inline int getHopSize()
Returns

the hop size

inline int getWindowSize()
Returns

the window size

float spectralFlatness()
Returns

the spectral flatness of the most recent FFT calculation

float spectralCentroid()
Returns

the spectral centroid of the most recent FFT calculation

class maxiIFFT

Inverse FFT transform

Subclassed by maxiIFFTAdaptor

Public Types

enum fftModes

Configure what kind of data is being given to the inverse FFT

Values:

enumerator SPECTRUM

Magnitudes and phases

enumerator COMPLEX

Real and imaginary components

Public Functions

void setup(int fftSize = 1024, int hopSize = 512, int windowSize = 0)

Configure the Inverse FFT.

Parameters
  • fftSize – the FFT size. This must be a power of 2

  • hopSize – the hop size

  • windowSize – the window size

float process(std::vector<float> &data1, std::vector<float> &data2, fftModes mode = maxiIFFT::SPECTRUM)

Run the inverse transform. Call this function at audio rate, but update the FFT information at FFT rate. See example 20.

Parameters
  • data1 – either magnitudes or real values

  • data2 – either phases or imaginary values

  • mode – see fftModes

Returns

the most recent sample an audio signal, creates from the inverse transform of the FFT data

inline int getNumBins()
Returns

the number of fft bins

class maxiFFTOctaveAnalyzer

An octave analyser. It takes FFT magnitudes and remaps them into pitches

Public Functions

void setup(float samplingRate, int nBandsInTheFFT, int nAveragesPerOctave)

Setup the octave analyser

Parameters
  • samplingRate – the sample rate

  • nBandsInTheFFT – the number of bins in the FFT

  • nAveragesPerOctave – how many frequency bands to split each octave into

void calculate(float *fftData)

Run the analyser

Parameters

fftData – a pointer to an array of fft magnitudes

Public Members

int nAverages

the number of averages, after analysis

float *averages

An array of averages - the energy across the pitch spectrum