Loading and Unloading Audio Library Memory

Status
Not open for further replies.

tenkai

Well-known member
Hello!

I have a project which I have been working on for a while now, which I would like to use the Audio library for, but only sometimes.

The device I am building takes up most of the memory of the Teensy 3.1 in its normal mode, however I would like to have a secondary mode where the primary function is disabled, and the audio library is enabled, and then the audio library can be disabled again and the primary loop can resume.

I guess my question is, does anyone know of a way to reliably de-allocate memory that has been allocated using AudioMemory()?
What about for other Audio objects? Specifically I will need to do a 4 channel note frequency analysis.

Thank you!
Tenkai
 
Last edited:
Hello!

I guess my question is, does anyone know of a way to reliably de-allocate memory that has been allocated using AudioMemory()?

This is not possible.

But you could try to edit Audiostream.h (in cores/teensy3/) and write your own function do allocate and de-allocate the memory. I guess you have to stop the whole library, too ..somehow.. ..as there are interrupts every 2.9ms which call the the object's update()-functions
 
Yeah, the whole library is designed to keep running forever. Making it stop would require some crafty hacking!

In theory, you should only need to look at the input and output objects. If you can modify those to stop, the entire library will stop, because they're the part which triggers the software interrupt which does all the updates.
 
Thanks Paul, I will have to look into this deeper. Once I figure something out, I will share my findings.

It would be great to have this as a standard across the board for all Audio objects.
 
Status
Not open for further replies.
Back
Top