Multiple SetAudioCallbacks


#1

Hello Everybody.
I made a little audio app which has a filetree component that lets the user browse the computer files and drag them into a draganddroptarget component. This browser gives the possibility to play audio files (.wav and .aif) if selected in the tree, and this is done with a setaudiocallback to the main audiodevicemanager.
It works.
When an audio file is dropped into the draganddroptarget component a little sampler component is created, and this sampler makes a new setaudiocallback to the main audiodevicemanager.
Now, I can play my audio file with a keyboard, but if I go back to the browser and try to listen to another file, nothing happens.
I think that the sampler “stealed” the callback to the audiodevicemanager and the browser has no more connections with it.
So my question is: is it possible to make multiple audiocallbacks to the audiodevicemanager?


#2

No, that’s not possible - that class is really just a top-level manager for the device, and if you need to have multiple streams you’d have to either switch them around as needed, or use a mixer source that lets you attach multiple simultaneous streams.


#3

So fast!
Thank you Jules, you’re great!
I’ll mix the streams…


#4

I’m having a little trouble with mixing up audio callbacks too (probably because i’m doing it wrong). I have a tabbed component with 2 tabs so far and i’ve loaded a class into each tab. Each class has its own AudioDeviceManager and IOCallback but one of them seems to be having problems during runtime. Should I only have one manager in the main component and have that deal with both of them?


#5

Yes man!
You need only one audiodevicemanager. Put it on the toplevel of your app, then create a mixeraudiosource and add callbacks from your tabs to it.
This worked for me.


#6

I’m actually having problems with the MixerAudioSource. Whenever I add more than one input source the synth playback sounds horrible. Do I need to do more than just addInputSource() to the mixer?


#7

It’ll work as long as your input sources are both working correctly, and aren’t messing each other up!