Предполагая, что у вас есть идентификатор устройств ввода и вывода, вы можете использовать что-то вроде следующего, чтобы получить соответствующие идентификаторы микшера. Если оба одинаковы, оба подключены к одному микшеру и, скорее всего, являются частью одного и того же физического оборудования.
/// <summary>
/// Get the ID of the mixer associated with the given input device ID
/// Returns -1 if no such mixer can be found
/// </summary>
static public int GetMixerIdInput(int inputId)
{
int mixerId = -1;
int result = MmeMixerApi.mixerGetID(inputId, ref mixerId, MIXER_OBJECTFLAG.WAVEIN);
if (((MMError)result != MMError.MMSYSERR_NOERROR) &&
((MMError)result != MMError.MMSYSERR_NODRIVER))
{
throw new MmeException((MMError)result);
}
return mixerId;
}
/// <summary>
/// Get the ID of the mixer associated with the given output device ID
/// Returns -1 if no such mixer can be found
/// </summary>
static public int GetMixerIdOutput(int outputId)
{
int mixerId = -1;
int result = MmeMixerApi.mixerGetID(outputId, ref mixerId, MIXER_OBJECTFLAG.WAVEOUT);
if (((MMError)result != MMError.MMSYSERR_NOERROR) &&
((MMError)result != MMError.MMSYSERR_NODRIVER))
{
throw new MmeException((MMError)result);
}
return mixerId;
}
Если у вас есть только имя для устройства ввода, вы можете использовать что-то вроде следующего, чтобы найти идентификатор устройства:
/// <summary>
/// Find the ID of the input device given a name
/// </summary>
static public int GetWaveInputId(string name)
{
int id = MmeWaveApi.WAVE_MAPPER;
int devCount = MmeWaveApi.waveInGetNumDevs();
WAVEINCAPS caps = new WAVEINCAPS();
for (int dev = 0; (dev < devCount) && (id == MmeWaveApi.WAVE_MAPPER); dev++)
{
int result = MmeWaveApi.waveInGetDevCaps(dev, ref caps, Marshal.SizeOf(caps));
if ((MMError)result == MMError.MMSYSERR_NOERROR)
{
if (string.Compare(name, 0, caps.szPname, 0, Math.Min(name.Length, caps.szPname.Length)) == 0)
{
id = dev;
}
}
}
return id;
}