Name of INPUT-Device from AudioIODevice


I have created a subclass of AudioAppComponent and instanciated an AudioDeviceManager with my audio devices like so:

ProcessorHost() : AudioAppComponent(adm) {
    AudioDeviceManager::AudioDeviceSetup deviceSetup = Config::getInstance()->getDeviceSetup();
    std::cout << deviceSetup.inputDeviceName << " | " << deviceSetup.outputDeviceName << std::endl;
	//returns "MacBook Air Mikrofon | MacBook Air-Lautsprecher" as these are the configured devices in deviceSetup.
    adm.initialise(2, 2, nullptr, false, "", &deviceSetup);
    setAudioChannels(adm.getCurrentAudioDevice()->getActiveInputChannels().countNumberOfSetBits(), 			adm.getCurrentAudioDevice()->getActiveOutputChannels().countNumberOfSetBits());

I know, that I can list all available INPUT and OUTPUT devices like this, where the bool-value in “getDeviceNames(bool)” indicates which type gets returned:

void ProcessorHost::listAvailableDevices() {
    for (auto devicetype : adm.getAvailableDeviceTypes()) {
		//INPUT devices
        for (const auto& devicename : devicetype->getDeviceNames(true)) {
            std::cout << devicename.toStdString() << std::endl;
		//OUTPUT devices
        for (const auto& devicename : devicetype->getDeviceNames(false)) {
            std::cout << devicename.toStdString() << std::endl;

Great so far. I also know, that I can get the current selected OUTPUT-devicename from the AudioDeviceManager (in my case adm) like so:

adm.getCurrentAudioDevice()->getName(); // returns "MacBook Air-Lautsprecher"

But how do I get the current INPUT-devicename from the AudioDeviceManager? Maybe I am missing a bit from the docs, could someone please help?

1 Like

I too cannot figure this out!

In fact this code in juce_Mac_CoreAudio.cpp has a variable optimistically called combinedName … which seems to be the source of the confusion :slight_smile:

    auto combinedName = outputDeviceName.isEmpty() ? inputDeviceName
                                                   : outputDeviceName;

    if (inputDeviceID == outputDeviceID)
        return new CoreAudioIODevice (this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex);

    std::unique_ptr<CoreAudioIODevice> in, out;

    if (inputDeviceID != 0)
        in.reset (new CoreAudioIODevice (this, inputDeviceName, inputDeviceID, inputIndex, 0, -1));

    if (outputDeviceID != 0)
        out.reset (new CoreAudioIODevice (this, outputDeviceName, 0, -1, outputDeviceID, outputIndex));

    if (in == nullptr)   return out.release();
    if (out == nullptr)  return in.release();

    std::unique_ptr<AudioIODeviceCombiner> combo (new AudioIODeviceCombiner (combinedName, this));

Ah - I think you might be able to:


Then on the AudioDeviceType object

virtual int getIndexOfDevice (AudioIODevice* device, bool asInput) const = 0;

And then look it up in:

virtual StringArray getDeviceNames (bool wantInputNames = false) const = 0;

I’m going to give it a go!

Sorry to bump into this, did you succeed by doing so?

Sorry it’s so long ago I can’t even remember which project this was for now :frowning: