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

#include <OscillatorBank.h>

Public Member Functions

int init (int newWavetableLength, int newNumOscillators, float newSampleRate)
 
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 (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.

Examples:
oscillator-bank/render.cpp.

Member Function Documentation

int OscillatorBank::init ( int  newWavetableLength,
int  newNumOscillators,
float  newSampleRate 
)
inline

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

Parameters
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.
newSampleRatethe sampling rate of the output samples. This affects the internal scaling of the oscillator frequencies.
Returns
0 upon success, a negative value otherwise.
Examples:
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:
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:
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:
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:
oscillator-bank/render.cpp.
void OscillatorBank::clearArrays ( )
inline

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

void OscillatorBank::process ( 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:
oscillator-bank/render.cpp.

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