Audio lib for non real-time processing?

Status
Not open for further replies.

chipaudette

Well-known member
Hi All,

I'm used to using the Audio Library with my Teensy Audio Board to do real-time processing. But, how do I use the audio library for non-real-time processing?

The scenario that I need to address is that my audio processing algorithms are too slow. To figure out which parts of my algorithm are too slow, I need to be able to run the whole stack, even if it takes longer than real time. But, on my setup (with the Teensy Audio Board), the whole thing freezes if it takes longer than real time. How can I use the Audio Library without the real-time requirement imposed by the Teensy Audio Board?

Ideally, I'd do something like: (1) read audio from SD card, (2) process with my too-slow algorithms, (3) debug by watching Serial.println() to the Serial Monitor, (4) write the processed audio to the SD card to confirm that it sounds OK.

Any idea how I'd do that?

Chip
 
You could try to call the update functions of your blocks individually, and take a look at the consumed cycles.
In most cases in the audiolibrary the output block takes care of calling the audio update functions of all connected blocks. (there is a static variable in audiostream which is the start of the list of audioblocks)
If you write your own audio output library which writes to sd you should be able to control the speed.
 
Last edited:
You could try using the queue objects. They give your Arduino sketch access to the raw 128 sample blocks.

Perhaps grab a several dozen blocks of data. Then turn off the data with a mixer, or just ignore the incoming blocks and let the audio library run out of memory (it'll be forced to discard data).

Do your audio processing at your leisure. When you're ready to use the library again, if it ran out of memory rapidly receive & discard all queued blocks. Then you can transmit your data into a play queue if you want to push it back into the library, to hear it or do other things.
 
Status
Not open for further replies.
Back
Top