I am trying to use the mixerGetLineInfo
and mixerGetLineControls
functions to get access to the the volume control for the default recording device opened with waveIn. I have written C# interop code that can successfully enumerate through all the sources destinations and controls in the system, but working out which is the control associated with the default waveIn device has so far eluded me. Does anyone have some sample code that does this?
views:
485answers:
1
+1
A:
You could use:
int mixerId = -1;
int inputID = MmeMixerApi.WAVE_MAPPER; // = -1
int result = MmeMixerApi.mixerGetID(inputId, ref mixerId, MIXER_OBJECTFLAG.WAVEIN);
The default input and output devices can be accessed through the wave mapper which has an ID of -1. mixerGetID will return the mixer ID associated with that input. You can then use the mixer ID to iterate over the controls. You would still need to find the correct source line (e.g. microphone, line-in etc.). For this you may want to look for a source line with a particular dwComponentType such as MIXERLINE_COMPONENTTYPE.SRC_MICROPHONE or MIXERLINE_COMPONENTTYPE.SRC_LINE.
Han
2009-03-16 08:25:43
where did you get the MmeMixerApi from?
Mark Heath
2009-03-16 20:00:00
MmeMixerApi is just a static class that encapsulates the P/Invoke MME mixer calls. I use a similar class named MmeWaveApi. Both are a mix of code found on the net, and my own additions and deletions.
Han
2009-03-16 21:08:34
I get the NoDriver error when calling mixerGetID with an inputID of -1
Mark Heath
2009-03-18 22:04:40
Didn't expect that, but I must admit I had not tried this with WAV_MAPPER. You could iterate over all input devices using waveInGetDevCaps, and compare the WAVEINCAPS.szPname fields. The ID of the device that matches the name of the device with ID=WAVE_MAPPER could be used in the call to mixerGetID.
Han
2009-03-19 08:34:40