如何调整pc的麦克输入音量

闲话不说了,直接上代码吧: int    AdjustAudioInputVolum (   DWORD   dwLineInID   ,  int   nStep  ) {         HMIXER               hMixer ;      MIXERLINE            mxl ;        MIXERLINECONTROLS   mxlc        MIXERCONTROL         mxc           dwLineInID  =0 ;  //-1 not get device id!      MMRESULT   mres   MMSYSERR_NOERROR ;      for   int   deviceID  =0 ;  true   deviceID   ++ )     {                mres   mixerOpen   (  hMixer ,              deviceID  ,                   0,                   0,                    MIXER_OBJECTF_MIXER  );              if   MMSYSERR_NOERROR   !=  mres  )         {              break  ;         }          ZeroMemory  ( mxl   sizeof (   MIXERLINE  ));          mxl  . cbStruct   sizeof (   MIXERLINE  );          mxl  . dwComponentType   MIXERLINE_COMPONENTTYPE_DST_WAVEIN  ;               MMRESULT   mres     =  mixerGetLineInfo ((   HMIXEROBJ  ) hMixer   ,               mxl  ,              MIXER_OBJECTF_HMIXER  | MIXER_GETLINEINFOF_COMPONENTTYPE   );          if   mres   !=  MMSYSERR_NOERROR  )         {              continue  ;         }          DWORD      dwConnections      =    mxl .   cConnections  ;     
         BOOL   bFoundMicro   FALSE ;          for   DWORD   i =0 ;  i   dwConnections   i ++ )         {              mxl  . dwSource   i ;              mres   mixerGetLineInfo   (   (  HMIXEROBJ )   hMixer  ,   mxl   ,                  MIXER_OBJECTF_HMIXER     |    MIXER_GETLINEINFOF_SOURCE      );                       if   MMSYSERR_NOERROR   ==  mres  )             {                  if   mxl  . dwComponentType   ==  MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE   //found microphone                 {                      dwLineInID   mxl   .  dwLineID //get lineIn device id.                      bFoundMicro   TRUE   ;                      break  ;                 }             }         }                 if  (! bFoundMicro   )              continue  ;                ZeroMemory  ( mxc   sizeof (   MIXERCONTROL  ));          mxc  . cbStruct   sizeof (   mxc  );                 ZeroMemory  ( mxlc   sizeof (   MIXERLINECONTROLS  ));          mxlc  . cbStruct   sizeof (   mxlc  );          mxlc  . dwLineID   dwLineInID ;               mxlc  . dwControlType   MIXERCONTROL_CONTROLTYPE_VOLUME ;          mxlc  . cControls   = 1;                  mxlc  . pamxctrl   =  mxc ;                 mxlc  . cbmxctrl   sizeof (   mxc  );              mres   mixerGetLineControls   ((  HMIXEROBJ )   hMixer  ,               mxlc  ,              MIXER_GETLINECONTROLSF_ONEBYTYPE  );                if  ( MMSYSERR_NOERROR   ==  mres )         {                        MIXERCONTROLDETAILS           mxcd ;                 MIXERCONTROLDETAILS_SIGNED   volStruct   ;                      ZeroMemory  ( mxcd   sizeof (   mxcd  ));              mxcd  . cbStruct   sizeof (   mxcd  );                   mxcd  . dwControlID   mxc .   dwControlID  ;              mxcd  . paDetails   =  volStruct ;                     mxcd  . cbDetails   sizeof (   volStruct  );              mxcd  . cChannels   = 1;                                      mres   mixerGetControlDetails   ((  HMIXEROBJ )   hMixer  ,                   mxcd  ,                  MIXER_GETCONTROLDETAILSF_VALUE  );              if  ( MMSYSERR_NOERROR   ==  mres )             {                  long   step   = (  mxc .   Bounds  . lMaximum   mxc .   Bounds  . lMinimum   ) /100;                  int   index   = (  volStruct .   lValue   mxc   .  Bounds .   lMinimum  ) / step  ;                                 if  ( index   !=  nStep )                 {                      volStruct  . lValue   nStep  *  step  ;                      mres   mixerSetControlDetails   ((  HMIXEROBJ )   hMixer  ,                           mxcd  ,                          MIXER_SETCONTROLDETAILSF_VALUE  );
                     if  ( MMSYSERR_NOERROR   ==  mres )                          return     volStruct   .  lValue ;                 }             }         }     }      return  -1; }
最新回复(0)
/jishu6v6YBU_2BvSO9oZgJHDJL5lQNpNW5Z1K2nMiu13MjkFh4_3D4858468
8 简首页