Enabling/Disabling USB Audio at runtime

Davidelvig

Well-known member
I have a USB audio output at the end of my audio chain (as well as I2S to the SGTL5000)

once define in the design tool, and instantiated at the top of my code file, is there any way to disable that USB Audio at runtime, so that it would cease to be seen by a connected USB host as an Audio input?

Alternatively, could it be enabled at runtime?
 
Without modifying the library source code, you could insert a queue object, which has a begin() and end() method. It may do what you wanted.
 
I've done more testing.

iPad (9th generation) with iOS 18.1.1
GarageBand

USB Camera Adaptor
My Teensy 4.1-based MIDI controller

With USB_MIDI_SERIAL defined
I can send USB MIDI and the GarageBand receives and plays it.

With USB_MIDI_AUDIO_SERIAL defined
No luck.

I've tried these things:
  • with USB_MIDI_AUDIO_SERIAL still defined, removing the AudioOutputUSB object and any references
  • in USB_AUDIO.H, commenting out the begin() statement in
    AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
One app on the iPad (ThumbJam) still seem so t"see" the controller as a MIDI input and output, but does not respond to play i.e. when messages are being sent).

So, at the moment, I can:
  1. Use USB Audio; or
  2. Allow USB MIDI to iPads
with different firmware builds.

I expect the hook to USB Audio comes in instantiation of classes, before loop() is called.

Any ideas for how to get the best of both worlds?

(BTW, the Apple USB Camera adaptor appears key to USB MIDI to the iPad. A standard USB C to Lightning does not result in a detected MIDI controller.)
 
Back
Top