Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Enable / Disable audio objects programmatically

  1. #1
    Junior Member
    Join Date
    Oct 2016
    Posts
    13

    Enable / Disable audio objects programmatically

    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!

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,583
    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.

  3. #3
    Junior Member
    Join Date
    Oct 2016
    Posts
    13
    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!!!

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,583
    You’re welcome! I’m always happy to share my modest knowledge bits and experience.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •