Public Member Functions | |
AudioSynthWavetable (void) | |
Class constructor. | |
void | setInstrument (const instrument_data &instrument) |
Set the instrument_data struct to be used as the playback instrument. More... | |
void | amplitude (float v) |
Changes the amplitude to 'v'. More... | |
void | stop (void) |
Stop playing waveform. More... | |
void | playFrequency (float freq, int amp=DEFAULT_AMPLITUDE) |
Play waveform at defined frequency, amplitude. More... | |
void | playNote (int note, int amp=DEFAULT_AMPLITUDE) |
Play sample at specified note, amplitude. More... | |
bool | isPlaying (void) |
void | setFrequency (float freq) |
Set various integer offsets to values that will produce intended frequencies. More... | |
virtual void | update (void) |
Called by the AudioStream library to fill the audio output buffer. More... | |
envelopeStateEnum | getEnvState (void) |
Static Public Member Functions | |
static float | midi_volume_transform (int midi_amp) |
Scale midi_amp to a value between 0.0 and 1.0 using a logarithmic tranformation. More... | |
static float | noteToFreq (int note) |
Convert a MIDI note value to its corresponding frequency. More... | |
static int | freqToNote (float freq) |
Convert a frequency to the corressponding MIDI note value. More... | |
|
inline |
Changes the amplitude to 'v'.
A value of 0 will set the synth output to minimum amplitude (i.e., no output). A value of 1 will set the output to the maximum amplitude. Amplitude is set linearly with intermediate values.
v | a value between 0.0 and 1.0 |
|
inlinestatic |
Convert a frequency to the corressponding MIDI note value.
freq | the frequency value as a float to convert |
|
inlinestatic |
Scale midi_amp to a value between 0.0 and 1.0 using a logarithmic tranformation.
midi_amp | a value between 0 and 127 |
|
inlinestatic |
Convert a MIDI note value to its corresponding frequency.
note | a value between 0 and 127 |
void AudioSynthWavetable::playFrequency | ( | float | freq, |
int | amp = DEFAULT_AMPLITUDE |
||
) |
Play waveform at defined frequency, amplitude.
freq | Frequency of note to playback, value between 1.0 and half of AUDIO_SAMPLE_RATE_EXACT |
amp | Amplitude scaling of note, value between 0-127, with 127 being base volume |
void AudioSynthWavetable::playNote | ( | int | note, |
int | amp = DEFAULT_AMPLITUDE |
||
) |
Play sample at specified note, amplitude.
note | Midi note number to playback, value between 0-127 |
amp | Amplitude scaling of playback, value between 0-127, with 127 being base volume |
void AudioSynthWavetable::setFrequency | ( | float | freq | ) |
Set various integer offsets to values that will produce intended frequencies.
the main integer offset, tone_incr, is used to step through the current sample's 16-bit PCM audio sample. Specifically, the tone_incr is the rate at which the interpolation code in update() steps through uint32_t space. The remaining offset variables represent a minimum and maximum offset allowed for tone_incr, which allows for low-frequency variation in playback frequency (aka vibrato). Further details on implementation in update() and in sample_data.h.
freq | frequency of the generated output (between 0 and the board-specific sample rate) |
|
inline |
Set the instrument_data struct to be used as the playback instrument.
A wavetable uses a set of samples to generate sound. This function is used to set the instrument samples.
instrument | a struct of type instrument_data, commonly prodced from a decoded SoundFont file using the SoundFont Decoder Script which accompanies this library. |
void AudioSynthWavetable::stop | ( | void | ) |
Stop playing waveform.
Waveform does not immediately stop, but fades out based on release time.
|
virtual |
Called by the AudioStream library to fill the audio output buffer.
The major parts are the interpoalation stage, and the volume envelope stage. Further details on implementation included inline.