none
Microphone volume RRS feed

  • Question

  • Hello, I'm just trying to adjust the mic volume, I copied the following code, but the MIXER_OBJECTF_WAVEIN const is not declared. Do I have to use a library?i cant use this code,please help me how to use this code for mute microphone in windows XP

    Best Regards

    -----------------------------------------------------------------------------------

    public static void SetMicVolume(int mxid, int percentage)
      {
        bool rc;
        int mixer, vVolume;
        MIXERCONTROL volCtrl = new MIXERCONTROL();
        int currentVol;
        mixerOpen(out mixer, mxid, 0, 0, MIXER_OBJECTF_WAVEIN);
        int type = MIXERCONTROL_CONTROLTYPE_VOLUME;
        rc = GetVolumeControl(mixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, type, out volCtrl, out currentVol);
        if (rc == false)
        {
          mixerClose(mixer);
          mixerOpen(out mixer, 0, 0, 0, 0);
          rc = GetVolumeControl(mixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, type, out volCtrl, out currentVol);
          if (rc == false)  
            throw new Exception("SetMicVolume/GetVolumeControl() failed");
        }
        vVolume = ((int)((float)(volCtrl.lMaximum - volCtrl.lMinimum) / 100.0F) * percentage);
        rc = SetVolumeControl(mixer, volCtrl, vVolume);
        if (rc == false)
          throw new Exception("SetMicVolume/SetVolumeControl() failed");
        mixerClose(mixer);
      }

    Tuesday, July 10, 2012 10:33 AM