No such device (but used anyway)


#1

Hi,

I am using the AudioDeviceManager to use a specific soundcard connected to a PC. For some reason, when trying to select the soundcard, I get an error: 'No such device: MOTU AVB USB ASIO' but the device is still used when I play back a sound.

 

If I print out the available devices and device types then I can clearly see that the soundcard shows up.

 

I am using the following code to print the devices and select the card:

OwnedArray<AudioIODeviceType> types;

deviceManager.createAudioDeviceTypes(types);

OwnedArray<AudioIODevice> devices;

for (int i = 0; i < types.size(); ++i){

    String typeName(types[i]->getTypeName());

    types[i]->scanForDevices();

    StringArray deviceNames(types[i]->getDeviceNames());

    for (int j = 0; j < deviceNames.size(); ++j){

        AudioIODevice* device = types[i]->createDevice(deviceNames[j], deviceNames[j]);

        devices.add(device);

    }

}

for (int i = 0; i < devices.size(); ++i){

    String type = devices[i]->getTypeName();

    String name = devices[i]->getName();

    std::cout << "type: " << type << ". device: " << name << std::endl;

}

//at this point I print out the following:
type: Windows Audio. device: Digital Audio (S/PDIF)
...
type: ASIO. device: MOTU AVB USB ASIO

//now I try to initialize with the MOTU
String error = deviceManager.initialise(0, 24, nullptr, true, "MOTU AVB USB ASIO");

if (error.isNotEmpty())
{
    std::cout << error << std::endl;
}

deviceManager.setCurrentAudioDeviceType("ASIO", true);

 

Does anyone know what this is happening?

 

 

EDIT:

 

It seems to work when I remove ASIO from the string when I initialise the deviceManager:

deviceManager.initialise(0, 24, nullptr, true, "MOTU AVB USB");

 


#2

Yeah, hard-coding device names into your app isn't a great idea. Not sure why the suffix would make a difference, but you should probably be looking at the list of names and scanning for a match rather than trying to open one with a specific name.