Revamped Audio Class in libDaisy

Hey everyone.

I’m about to merge a fairly large PR that reworks a lot of the internal guts of the Audio in libDaisy.

The PR covers the following:

  • SAI and Audio are now written in C++
  • Easier configuration of SAI with SaiHandle::Config struct
  • The ability to run the SAI without the Audio engine (if you want direct to hardware support with non-floating point values).
  • Ability to run Audio at various common samplerates (8kHz, 16kHz, 32kHz, 48kHz, and 96kHz)
  • A common API for audio across all breakout boards including the Daisy Seed.

If you’ve been using the DaisySeed, or other Daisy”Board” classes then very little, if anything, will have changed for you (The DaisyField had different names for some functions, like SampleRate vs AudioSampleRate).

However, if you were using the hid/audio.h functions directly, they have all been changed, and the DSY_AUDIO_SAMPLE_RATE macro has been removed. This will potentially break some earlier projects.

The DaisySeed, and other board classes will now have the following functions:

  • StartAudio(AudioHandle::AudioCallback cb)
  • StartAudio(AudioHandle::InterleavingAudioCallback cb)
  • ChangeAudioCallback(AudioHandle::AudioCallback cb)
  • ChangeAudioCallback(AudioHandle::InterleavingAudioCallback cb)
  • StopAudio()
  • SetAudioSampleRate(SaiHandle::Config::SampleRate samplerate)
  • SetAudioBlockSize(size_t size)
  • AudioSampleRate()
  • AudioBlockSize()
  • AudioCallbackRate()

Since this is a pretty substantial update, I wanted to give everyone a heads up, and let them know. If anyone has any questions feel free to let me know!


I am using a test program to attempt to fix the massive 1kHz noise I am seeing. The program passes audio fine (just using out[0][i] = in[0][i]) when I use 48kHz, but no audio is passed when I change the samplerate to 96kHz. The only line I am changing is:




When I change the samplerate to 32kHz & 16kHz audio passes.

I know the samplerate is changing because the 1kHz noise line moves around as it should (samplerate/blocksize) when I go to 96kHz…just no audio seems to pass. I am not sure what I could be doing incorrectly since the other samplerates seem to pass audio just fine.