Audio Library Interrupt Frequency

Status
Not open for further replies.

Cosford

Well-known member
Hi All,

I know this is definitely in here somewhere but after twenty minutes of searching I figured i'd just ask.
I'm playing WAV audio via sd card using the audio library. Simply fed into a mixer and to the t3.2 DAC.

What frequency does the interrupt go off? The number 3.7ms is stuck in my head for some reason...

Additionally, are there any issues with using AudioNoInterrupts() prior to some time critical code (~720uS) and then re-enabling interrupts? Or would that disrupt the playback?

Cheers.
 
It's my understanding that the whole Audio Library operates on 128-point blocks at a sample rate of ~44.1kHz. If this is correct, the interrupt would occur every 128/44100 = 0.0029 sec = 2.9 msec.

Chip
 
It's my understanding that the whole Audio Library operates on 128-point blocks at a sample rate of ~44.1kHz. If this is correct, the interrupt would occur every 128/44100 = 0.0029 sec = 2.9 msec.

Chip

Ah yes, that rings a bell. Cheers.
 
The audio library has 2 types of interrupts, high priority and low priority.

The high priority interrupts are for DMA and other hardware. Each hardware object is different. Some may interrupt more frequently than every 128 samples. These high priority interrupts have very short duration.

The low priority interrupt runs every 128 samples. It's triggered by one of the high priority interrupts, which is the reason why all designs must have at least one hardware input or output object. The low priority interrupt does all the CPU intensive work. The idea is to allow the hardware-based interrupts, and interrupts for USB, serial and other libraries you're using to still function properly while the audio library does its DSP work.
 
Thanks for that Paul.
For my usage scenario then; SdWav->mixer->DAC, please correct me if I'm wrong but I'm simply guessing that I'm looking at an interrupt every 128 samples to fetch the next sample from the SD card, and to apply the mixer's gain value to the sample.

From there on, does the DAC object trigger any more interrupts or does it just run from DMA?
 
Yes, that's pretty much how it works.

Have you got this running? It should "just work" when you connect those objects together and fill in the minimal Arduino code to start it running.
 
Great, thanks.
It works beautifully, just wanted to get my head around the details a little more as I'd observed some LED glitching using WS2812's with the FastLED library. Resolved the issue by stopping FastLED reenabling interrupts between sending out data for each LED, but wanted to understand exactly what was going on behind the scenes in the audio library with regard to interrupts.
 
Status
Not open for further replies.
Back
Top