Assuming you have the ID of the input and output devices, you could use something like the following to get the corresponding mixer IDs. If both are the same, both are attached to the same mixer, and most likely part of the same physical hardware.
/// <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;
}
If you only have the name for the input device, you can use something like the following to find the device ID:
/// <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;
}