daisy::AudioHandle¶
Module: LIBDAISY / HUMAN_INTERFACE / AUDIO
Audio Engine Handle. More...
#include <audio.h>
Public Classes¶
Name | |
---|---|
struct | Config |
Public Types¶
Name | |
---|---|
enum class | Result |
typedef const float *const * | InputBuffer |
typedef float ** | OutputBuffer |
typedef void(*)(InputBuffer in, OutputBuffer out, size_t size) | AudioCallback |
typedef const float * | InterleavingInputBuffer |
typedef float * | InterleavingOutputBuffer |
typedef void(*)(InterleavingInputBuffer in, InterleavingOutputBuffer out, size_t size) | InterleavingAudioCallback |
Public Functions¶
Name | |
---|---|
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) |
Detailed Description¶
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:
- Create and Initialize an SaiHandle or two depending on your requirements
- Initialize the Audio Handle with the desired settings and the Initialized SaiHandle
- If the connected codec requires special configuration or initialization, do so
- Write a callback method using either the AudioCallback or the InterleavingAudioCallback format
- Start the Audio using one of the StartAudio function
Public Types Documentation¶
enum Result¶
Enumerator | Value | Description |
---|---|---|
OK | ||
ERR |
typedef InputBuffer¶
Non-Interleaving input buffer Buffer arranged by float[chn][sample] const so that the user can't modify the input
typedef OutputBuffer¶
Non-Interleaving output buffer Arranged by float[chn][sample]
typedef AudioCallback¶
Type for a Non-Interleaving audio callback Non-Interleaving audio callbacks in daisy will be of this type
typedef InterleavingInputBuffer¶
Interleaving Input buffer audio is prepared as { L0, R0, L1, R1, . . . LN, RN }] this is const, as the user shouldn't modify it
typedef InterleavingOutputBuffer¶
Interleaving Output buffer audio is prepared as { L0, R0, L1, R1, . . . LN, RN }
typedef InterleavingAudioCallback¶
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
Public Functions Documentation¶
function AudioHandle¶
function ~AudioHandle¶
function AudioHandle¶
function operator=¶
function Init¶
Initializes audio to run using a single SAI configured in Stereo I2S mode.
function Init¶
Initializes audio to run using two SAI, each configured in Stereo I2S mode.
function DeInit¶
Stops and deinitializes audio.
function GetConfig¶
Returns the Global Configuration struct for the Audio
function GetChannels¶
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
function GetSampleRate¶
Returns the Samplerate as a float
function SetSampleRate¶
Sets the samplerate, and reinitializes the sai as needed.
function SetBlockSize¶
Sets the block size after initialization, and updates the internal configuration struct. Get BlockSize and other details via the GetConfig
function SetPostGain¶
Parameters:
- val Gain adjustment amount. The hardware will clip at the reciprical of this value.
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
function SetOutputCompensation¶
Parameters:
- 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 an additional amount of gain compensation to perform at the end of the callback Useful if the hardware input/output levels are not equal.
function Start¶
Starts the Audio using the non-interleaving callback.
function Start¶
Starts the Audio using the interleaving callback. For now only two channels are supported via this method.
function Stop¶
Stop the Audio
function ChangeCallback¶
Immediatley changes the audio callback to the non-interleaving callback passed in.
function ChangeCallback¶
Immediatley changes the audio callback to the interleaving callback passed in.
---¶
Updated on 2024-01-03 at 19:41:01 +0000