Audio Engine Handle. More...
Audio Engine Handle.
This class allows for higher level access to an audio engine. If you're using a SOM like the DaisySeed or DaisyPatchSM (or any board that includes one of those objects) then the intialization is already taken care of. If you're setting up your own custom hardware, or need to make changes you will have to take the following steps:
#include <audio.h>
Classes | |
struct | Config |
Public Types | |
enum class | Result { OK , ERR } |
typedef const float *const * | InputBuffer |
typedef float ** | OutputBuffer |
typedef void(* | AudioCallback) (InputBuffer in, OutputBuffer out, size_t size) |
typedef const float * | InterleavingInputBuffer |
typedef float * | InterleavingOutputBuffer |
typedef void(* | InterleavingAudioCallback) (InterleavingInputBuffer in, InterleavingOutputBuffer out, size_t size) |
Public Member Functions | |
AudioHandle () | |
~AudioHandle () | |
AudioHandle (const AudioHandle &other)=default | |
AudioHandle & | operator= (const AudioHandle &other)=default |
Result | Init (const Config &config, SaiHandle sai) |
Result | Init (const Config &config, SaiHandle sai1, SaiHandle sai2) |
Result | DeInit () |
const Config & | GetConfig () const |
size_t | GetChannels () const |
float | GetSampleRate () |
Result | SetSampleRate (SaiHandle::Config::SampleRate samplerate) |
Result | SetBlockSize (size_t size) |
Result | SetPostGain (float val) |
Result | SetOutputCompensation (float val) |
Result | Start (AudioCallback callback) |
Result | Start (InterleavingAudioCallback callback) |
Result | Stop () |
Result | ChangeCallback (AudioCallback callback) |
Result | ChangeCallback (InterleavingAudioCallback callback) |
typedef void(* daisy::AudioHandle::AudioCallback) (InputBuffer in, OutputBuffer out, size_t size) |
Type for a Non-Interleaving audio callback Non-Interleaving audio callbacks in daisy will be of this type
Non-Interleaving input buffer Buffer arranged by float[chn][sample] const so that the user can't modify the input
typedef void(* daisy::AudioHandle::InterleavingAudioCallback) (InterleavingInputBuffer in, InterleavingOutputBuffer out, size_t size) |
Interleaving Audio Callback Interleaving audio callbacks in daisy must be of this type
Interleaving Input buffer audio is prepared as { L0, R0, L1, R1, . . . LN, RN }] this is const, as the user shouldn't modify it
Interleaving Output buffer audio is prepared as { L0, R0, L1, R1, . . . LN, RN }
Non-Interleaving output buffer Arranged by float[chn][sample]
|
strong |
|
inline |
|
inline |
|
default |
Result daisy::AudioHandle::ChangeCallback | ( | AudioCallback | callback | ) |
Immediatley changes the audio callback to the non-interleaving callback passed in.
Result daisy::AudioHandle::ChangeCallback | ( | InterleavingAudioCallback | callback | ) |
Immediatley changes the audio callback to the interleaving callback passed in.
Result daisy::AudioHandle::DeInit | ( | ) |
Stops and deinitializes audio.
size_t daisy::AudioHandle::GetChannels | ( | ) | const |
Returns the number of channels of audio.
When using a single SAI this returns 2, when using two SAI it returns 4 If no SAI is initialized this returns 0
Eventually when we add non-standard I2S for each SAI this will be work differently
Returns the Global Configuration struct for the Audio
float daisy::AudioHandle::GetSampleRate | ( | ) |
Returns the Samplerate as a float
Initializes audio to run using a single SAI configured in Stereo I2S mode.
Initializes audio to run using two SAI, each configured in Stereo I2S mode.
|
default |
Sets the block size after initialization, and updates the internal configuration struct. Get BlockSize and other details via the GetConfig
Sets an additional amount of gain compensation to perform at the end of the callback Useful if the hardware input/output levels are not equal.
val | To calcuate the value, measure the input signal, then measure the output signal (with this set to default value of 1.0). Then calculate val as: val = 1 / (vout / vin); |
Sets the amount of gain adjustment to perform before and after callback. useful if the hardware has additional headroom, and the nominal value shouldn't be 1.0
val | Gain adjustment amount. The hardware will clip at the reciprical of this value. |
Result daisy::AudioHandle::SetSampleRate | ( | SaiHandle::Config::SampleRate | samplerate | ) |
Sets the samplerate, and reinitializes the sai as needed.
Result daisy::AudioHandle::Start | ( | AudioCallback | callback | ) |
Starts the Audio using the non-interleaving callback.
Result daisy::AudioHandle::Start | ( | InterleavingAudioCallback | callback | ) |
Starts the Audio using the interleaving callback. For now only two channels are supported via this method.
Result daisy::AudioHandle::Stop | ( | ) |
Stop the Audio