55#define SPK_MAX_VOLUME 255
uint32_t uq16_16
unsigned 16 bits integer, 16 bits fraction
Definition fp_math.h:42
oscAccum_t accumulator
An accumulator to increment the wave sample.
Definition swSynth.h:110
oscillatorShape_t
The different wave shapes that can be generated.
Definition swSynth.h:65
@ SHAPE_SAWTOOTH
A sawtooth wave.
Definition swSynth.h:67
@ SHAPE_SQUARE
A square wave.
Definition swSynth.h:69
@ SHAPE_SINE
A sine wave.
Definition swSynth.h:66
@ SHAPE_TRIANGLE
A triangle wave.
Definition swSynth.h:68
@ SHAPE_NOISE
Random noise from a linear feedback shift register.
Definition swSynth.h:70
void swSynthSetShape(synthOscillator_t *osc, oscillatorShape_t shape)
Set a software synthesizer oscillator's shape.
Definition swSynth.c:210
void swSynthSetFreqPrecise(synthOscillator_t *osc, uq16_16 freq)
Set the frequency of an oscillator with 16 bits of decimal precision.
Definition swSynth.c:273
int32_t swSynthSumOscillators(synthOscillator_t *oscillators[], uint16_t numOscillators)
Increment and mix together a set of oscillators like swSynthMixOscillators(), but returns the interme...
Definition swSynth.c:315
void swSynthSetWaveFunc(synthOscillator_t *osc, waveFunc_t waveFunc, void *waveFuncData)
Set the wave function of an oscillator.
Definition swSynth.c:250
uint32_t tVol
The target volume (amplitude)
Definition swSynth.h:112
void swSynthSetFreq(synthOscillator_t *osc, uint32_t freq)
Set the frequency of an oscillator.
Definition swSynth.c:262
uint8_t swSynthMixOscillators(synthOscillator_t *oscillators[], uint16_t numOscillators)
Increment a set of oscillators by one step each, mix together the resulting samples,...
Definition swSynth.c:298
uint32_t accum32
The oscillator value is accumulated in a 32 bit integer.
Definition swSynth.h:83
int8_t(* waveFunc_t)(uint16_t idx, void *data)
Function typedef to return a sample from a wave.
Definition swSynth.h:97
void swSynthSetVolume(synthOscillator_t *osc, uint8_t volume)
Set the volume (amplitude) of an oscillator.
Definition swSynth.c:285
uint32_t cVol
The current volume which smoothly transitions to the target volume.
Definition swSynth.h:113
int32_t stepSize
The step that should be added to the accumulator each sample, dependent on frequency.
Definition swSynth.h:111
uint8_t chorus
The number of offset samples to return.
Definition swSynth.h:114
int8_t swSynthSampleWave(oscillatorShape_t shape, uint8_t idx)
Definition swSynth.c:359
waveFunc_t waveFunc
A pointer to the function which generates samples.
Definition swSynth.h:108
void * waveFuncData
A pointer to pass to the wave function.
Definition swSynth.h:109
void swSynthInitOscillatorWave(synthOscillator_t *osc, waveFunc_t waveFunc, void *waveData, uint32_t freq, uint8_t volume)
Initialize a software synthesizer oscillator.
Definition swSynth.c:192
void swSynthInitOscillator(synthOscillator_t *osc, oscillatorShape_t shape, uint32_t freq, uint8_t volume)
Initialize a software synthesizer oscillator.
Definition swSynth.c:171
A software oscillator with controllable frequency, amplitude, and shape.
Definition swSynth.h:107
An accumulator used to increment through a wave. A value is accumulated in a 32-bit integer and bits ...
Definition swSynth.h:82