Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Member Functions | List of all members
OscillatorBank Class Reference

#include <OscillatorBank.h>

Public Member Functions

int setup (float newSampleRate, unsigned int newWavetableLength, unsigned int newNumOscillators)
 
float * getWavetable ()
 
int getWavetableLength ()
 
int getNumOscillators ()
 
float * getAmplitudes ()
 
float * getPhases ()
 
void setAmplitude (int n, float amplitude)
 
void setFrequency (int n, float frequency)
 
void clearArrays ()
 
void process (unsigned int frames, float *output)
 

Detailed Description

A class for computing a table-lookup oscillator bank. The internal routine is highly optimized, written in NEON assembly. All oscillators in the bank share the same wavetable. Linear interpolation is used.

Examples:
Extras/oscillator-bank/render.cpp.

Member Function Documentation

int OscillatorBank::setup ( float  newSampleRate,
unsigned int  newWavetableLength,
unsigned int  newNumOscillators 
)
inline

Initialize the oscillator bank, allocating the memory with the appropriate alignment required by the NEON code.

Parameters
newSampleRatethe sampling rate of the output samples. This affects the internal scaling of the oscillator frequencies.
newWavetableLengththe length of the wavetable. The internal wavetable will have length *(newWavetableLength + 1)*.
newNumOscillatorsthe number of oscillators to use. The class will internally increment and store the frequency, amplitude and phase of each oscillator.
Returns
0 upon success, a negative value otherwise.
Examples:
Extras/oscillator-bank/render.cpp.
float* OscillatorBank::getWavetable ( )
inline

Get the wavetable. It is the responsibilty of the user to fill it with the waveform that will be played by the oscillators. The internally stored wavetable will have length (getWavetableLength() + 1) The user should fill the last sample with the same value as the first sample.

Returns
a pointer to the wavetable array, of length (getWavetableLength() + 1)
Examples:
Extras/oscillator-bank/render.cpp.
int OscillatorBank::getWavetableLength ( )
inline

Get the length of the wavetable. The internally allocated array is actually of size getWavetableLength() + 1.

Returns
the length of the wavtable.
Examples:
Extras/oscillator-bank/render.cpp.
int OscillatorBank::getNumOscillators ( )
inline

Get the number of oscillators.

Returns
the number of oscillators.
float* OscillatorBank::getAmplitudes ( )
inline

Get the array of amplitudes. This array has length getNumOscillators()

Returns
a pointer to the array of amplitudes.
float* OscillatorBank::getPhases ( )
inline

Get the internal array of phases which hold the state of the oscillators. This array has length getNumOscillators()

Returns
a pointer to the arrat of phases.
void OscillatorBank::setAmplitude ( int  n,
float  amplitude 
)
inline

Sets the amplitude of a given oscillator.

Parameters
nthe oscillator to set
amplitudethe amplitude of the oscillator
Examples:
Extras/oscillator-bank/render.cpp.
void OscillatorBank::setFrequency ( int  n,
float  frequency 
)
inline

Sets the frequency for a given oscillator.

Parameters
nthe oscillator to set
frequencythe frequency of the oscillator
Examples:
Extras/oscillator-bank/render.cpp.
void OscillatorBank::clearArrays ( )
inline

Clears the internal arrays which hold the states of the oscillator bank.

void OscillatorBank::process ( unsigned int  frames,
float *  output 
)
inline

Process the oscillator bank, update the internal states and return the output values .

Parameters
framesthe number of frames to process
outputthe array where the frames output values will be stored.
Examples:
Extras/oscillator-bank/render.cpp.

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