I recently added a second audio interface to the Zoxnoxious synth module ( Using multiple audio interfaces ). The module now uses two objects derived from audio::Port. Functionally no issues on Linux and MacOS, I’m able to set both interfaces and a happy camper with playback.
What is not working is JSON save/restore of the objects on MacOS. This did work fine with a single interface, on patch load the single audio port is set. With two audio::Port objects save/restore also works fine in Linux. The issue is MacOS: with two audio::Port objects they do not get set on restore.
I took a look at the JSON between the two and am thinking it might be MacOS having the same name for the devices.
Here’s the relevant JSON on Linux:
"audioPort0": {
"driver": 1,
"deviceName": "hw:Zoxnoxious MIDI and Audio,0",
"sampleRate": 4000.0,
"blockSize": 256,
"inputOffset": 0,
"outputOffset": 0
},
"audioPort1": {
"driver": 1,
"deviceName": "hw:Zoxnoxious MIDI and Audio,1",
"sampleRate": 4000.0,
"blockSize": 256,
"inputOffset": 0,
"outputOffset": 0
}
On MacOS, I get the following:
"audioPort0": {
"driver": 5,
"deviceName": "Playback Inactive",
"sampleRate": 4000.0,
"blockSize": 256,
"inputOffset": 0,
"outputOffset": 0
},
"audioPort1": {
"driver": 5,
"deviceName": "Playback Inactive",
"sampleRate": 4000.0,
"blockSize": 256,
"inputOffset": 0,
"outputOffset": 0
}
}
Note the non-unique deviceNames.
I took a look at audio.cpp and Port::fromJson does rely on string matching of deviceName:
json_t* deviceNameJ = json_object_get(rootJ, "deviceName");
if (deviceNameJ) {
std::string deviceName = json_string_value(deviceNameJ);
// Search for device ID with equal name
for (int deviceId : getDeviceIds()) {
std::string deviceNameCurr = getDeviceName(deviceId);
if (deviceNameCurr == "")
continue;
if (deviceNameCurr == deviceName) {
setDeviceId(deviceId);
break;
}
}
}
I’m wondering what the options are at this point. Can MacOS provide unique deviceNames? Or maybe something in Rack on getDeviceIds() could help?