Enable / Disable audio objects programmatically

Status
Not open for further replies.

CanopyR&D

Member
Hey all,

I've got a project that I'd like to be flexible, and use many of the audio objects from the Audio library - but not all of them will be needed at once. I'm looking for a way to effectively toggle certain objects off. I haven't gotten much of a chance to mess around with the issue, so hopefully it's not something glaringly obvious.

I've thought to try out simply destroying the AudioConnection object between the two object's ports, but I'm unsure if this is the correct way to approach. I had hoped the source for AudioConnection would document something about programmatically connecting / disconnecting objects, but I was unable to locate the implementation in the github for the Audio library. I must be missing something there as well.

Any nudges in the right direction, or suggestions on how best to approach something like this while minimizing average CPU usage & Audio memory would be greatly appreciated!
 
The audio objects inherit from the AudioStream and AudioConnection classes, both declared in the AudioStream.h and AudioStream.cpp Teensyduino core files. From there, you can see that you can (since recent updates) not only connect, but also disconnect AudioConnection objects to reconfigure your audio setup at runtime. But there is no explicit destructor for objects derived from the AudioStream class. Thus, the answer to your question seems to be "no", at least for the moment.

But disconnecting an audio object from all queues will basically deactivate it, so that it does not eat CPU cycles. It will just continue to occupy a few bytes in the RAM.
 
Thank you very much for your reply - especially about tracking down the AudioConnection implementation. Seems to be working just as I need with the disconnect() & connect() functionality.

Thanks again!!!
 
Status
Not open for further replies.
Back
Top