tags:

views:

485

answers:

1

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?

+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
where did you get the MmeMixerApi from?
Mark Heath
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
I get the NoDriver error when calling mixerGetID with an inputID of -1
Mark Heath
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