Multiple AudioDeviceManagers for the same input or output?


#1

Juce to you all!

I'm continuing great guns with my Cythonization of Juce - which, after a rocky start, has been smooth sailing.

I did end up replacing the Colour stuff with my own - because I needed floating point colors (some of my instruments have 7-bit resolution per RGB component, and some have 12-bit - plus I want to do super-smooth fades) but generally everything just flowed through.

My question: I'm going to a reasonable amount of work to avoid creating two identical AudioDeviceManagers for the same input or output - but I now wonder whether this is worthwhile?  Is there significant overhead for each one?  I could simplify my code considerably if I just created one when I needed one and didn't worry if there were a "very similar" one already in existence...


#2

Juce to you too!

There's not much overhead in the AudioDeviceManager class itself, but the drawback of creating two of them is that each one will open its own set of device objects.. Opening multiple instances of the same device is probably a Bad Thing.. The worst-case scenario is that some drivers (e.g. some flaky old ASIO ones) may refuse to open the second instance. At best, you'll have extra OS overhead for each driver instance + twice as many threads serving them all. So although it'd probably all work, I wouldn't recommend it if you can avoid it.


#3

Good, good - this is what I was already doing.  I shall continue down this path, then.


#4

No, wait, this leads to an interesting issue.

In my application, I'm often wanting to be listening to an audio input just to get rough loudness levels.  I'm running on many different sorts of platforms, including small machines like the Raspberry Pi, so I've been running that at an 8K sample rate.

Sometimes, I want to actually record digital audio.  At that point, I open up a new input - at full sample rate.

Might this fail on old machines?  Should I instead close the 8K, open the 44.1K, and use that single input for both level calculation and recording?


#5

TBH it'll probably work on most machines.. If the extra overhead of running two devices isn't a problem, I wouldn't worry about it if I were you.