Is there anyway to enable ASIO loopback when using getRecordNumDrivers and getRecordDriverInfo?
Im using AudioStream to get a list of avalaible inputs to transmit in a voice chat, i enabled loopbacks so the player can transmit their PC audio. I also wanted to enable ASIO audio so players can use DAWs and instruments to communicate. Im able to show WASAPI inputs and lopbacks and ASIO input, but i dont know how to enable ASIO looback. my code for getting the audio inputs is this:
public static List<INPUT_DEVICE_INFO> AvailableInputs(LogLevel logLevel
, string gameObjectName
, EventWithStringStringParameter onError
, bool includeLoopbackInterfaces = true
)
{
// (make sure to not throw an exception anywhere so the system is always released)
var fmodsystem = FMOD_SystemW.FMODSystem0_Create(logLevel, gameObjectName, onError);
var result = fmodsystem.Update();
FMODHelpers.ERRCHECK(result, LogLevel.ERROR, "FMODSystemsManager.FMODSystemInputDevice", null, "fmodsystem.Update", false);
List<INPUT_DEVICE_INFO> availableDrivers = new List<INPUT_DEVICE_INFO>();
/*
Enumerate record devices
*/
int numAllDrivers = 0;
int numConnectedDrivers = 0;
result = fmodsystem.system.getRecordNumDrivers(out numAllDrivers, out numConnectedDrivers);
FMODHelpers.ERRCHECK(result, LogLevel.ERROR, "FMODSystemsManager.FMODSystemInputDevice", null, "fmodsystem.system.getRecordNumDrivers", false);
for (int i = 0; i < numAllDrivers; ++i)
{
int recChannels;
int recRate;
int namelen = 255;
string name;
System.Guid guid;
FMOD.SPEAKERMODE speakermode;
FMOD.DRIVER_STATE driverstate;
result = fmodsystem.system.getRecordDriverInfo(i, out name, namelen, out guid, out recRate, out speakermode, out recChannels, out driverstate);
FMODHelpers.ERRCHECK(result, LogLevel.ERROR, "FMODSystemsManager.FMODSystemInputDevice", null, "fmodsystem.system.getRecordDriverInfo", false);
if (result != FMOD.RESULT.OK)
{
Log.LOG(LogLevel.ERROR, logLevel, gameObjectName, "!error input {0} guid: {1} systemrate: {2} speaker mode: {3} channels: {4} state: {5}"
, name
, guid
, recRate
, speakermode
, recChannels
, driverstate
);
continue;
}
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
// hardcoded string added by FMOD to the adapter name on Windows
var isLoopback = name.ToLowerInvariant().EndsWith("[loopback]");
var addInterface = includeLoopbackInterfaces ? true : !isLoopback;
#else
var addInterface = true;
#endif
addInterface &= ((driverstate & FMOD.DRIVER_STATE.CONNECTED) == FMOD.DRIVER_STATE.CONNECTED)
|| ((driverstate & FMOD.DRIVER_STATE.DEFAULT) == FMOD.DRIVER_STATE.DEFAULT)
;
if (addInterface)
{
availableDrivers.Add(new INPUT_DEVICE_INFO() { id = i, name = name, guid = guid, samplerate = recRate, speakermode = speakermode, channels = recChannels, isDefault = (driverstate & FMOD.DRIVER_STATE.DEFAULT) == FMOD.DRIVER_STATE.DEFAULT });
}
Log.LOG(LogLevel.INFO, logLevel, gameObjectName, "{0} guid: {1} systemrate: {2} speaker mode: {3} channels: {4} state: {5} - {6}"
, name
, guid
, recRate
, speakermode
, recChannels
, driverstate
, addInterface ? "ADDED" : "SKIPPED (LOOPBACK)"
);
}
// release
FMOD_SystemW.FMODSystem0_Release(ref fmodsystem, logLevel, gameObjectName, onError);
return availableDrivers;
}
Any idea on how to archieve this?