程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> XP下,麥克風加強

XP下,麥克風加強

編輯:C++入門知識

[cpp]
bool CMicrophoneEnhance::SetEnhance(bool enhance, DWORD type) 

<span style="white-space:pre">  </span>MIXERLINE line, sub_line; 
<span style="white-space:pre">  </span>ZeroMemory(&line, sizeof(MIXERLINE)); 
<span style="white-space:pre">  </span>ZeroMemory(&sub_line, sizeof(MIXERLINE)); 
 
 
<span style="white-space:pre">  </span>HMIXER hMixer = NULL; 
<span style="white-space:pre">  </span>bool result = false; 
<span style="white-space:pre">  </span>int devs = ::mixerGetNumDevs(); 
<span style="white-space:pre">  </span>for(int i=0; i<devs; ++i) 
<span style="white-space:pre">  </span>{<span style="white-space:pre">  </span>// 
<span style="white-space:pre">      </span>if (::mixerOpen(&hMixer, i, (DWORD)0, 0, CALLBACK_WINDOW) != MMSYSERR_NOERROR)  
<span style="white-space:pre">      </span>{ 
<span style="white-space:pre">          </span>hMixer = NULL; 
<span style="white-space:pre">          </span>continue; 
<span style="white-space:pre">      </span>} 
<span style="white-space:pre">      </span>line.cbStruct<span style="white-space:pre">      </span>= sizeof(MIXERLINE); 
<span style="white-space:pre">      </span>line.dwComponentType = type; 
<span style="white-space:pre">      </span>if(::mixerGetLineInfo((HMIXEROBJ)hMixer,&line, MIXER_GETLINEINFOF_COMPONENTTYPE)!= MMSYSERR_NOERROR) 
<span style="white-space:pre">      </span>{ 
<span style="white-space:pre">          </span>::mixerClose(hMixer); 
<span style="white-space:pre">          </span>hMixer = NULL; 
<span style="white-space:pre">          </span>continue; 
<span style="white-space:pre">      </span>} 
 
 
<span style="white-space:pre">      </span>if(line.cConnections == 0)  
<span style="white-space:pre">      </span>{ 
<span style="white-space:pre">          </span>::mixerClose(hMixer); 
<span style="white-space:pre">          </span>hMixer = NULL; 
<span style="white-space:pre">          </span>continue; 
<span style="white-space:pre">      </span>} 
<span style="white-space:pre">      </span>int connections = line.cConnections; 
<span style="white-space:pre">      </span>for(int j=0; j<connections; ++j) 
<span style="white-space:pre">      </span>{ 
<span style="white-space:pre">          </span>sub_line<span style="white-space:pre">           </span>= line; 
<span style="white-space:pre">          </span>sub_line.dwSource<span style="white-space:pre">  </span>= j; 
<span style="white-space:pre">          </span>mixerGetLineInfo((HMIXEROBJ)hMixer, &sub_line, MIXER_GETLINEINFOF_SOURCE); 
 
 
<span style="white-space:pre">          </span>MIXERCONTROL<span style="white-space:pre">       </span>mxc; 
<span style="white-space:pre">          </span>MIXERLINECONTROLS<span style="white-space:pre">  </span>mxlc; 
<span style="white-space:pre">          </span>mxlc.cbStruct = sizeof(mxlc); 
<span style="white-space:pre">          </span>mxlc.dwLineID = sub_line.dwLineID; 
<span style="white-space:pre">          </span>mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_ONOFF; 
<span style="white-space:pre">          </span>mxlc.cControls = sub_line.cControls; 
<span style="white-space:pre">          </span>mxlc.cbmxctrl = sizeof(MIXERCONTROL); 
<span style="white-space:pre">          </span>mxlc.pamxctrl = &mxc; 
<span style="white-space:pre">          </span>if (MMSYSERR_NOERROR != ::mixerGetLineControls((HMIXEROBJ)hMixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)) 
<span style="white-space:pre">          </span>{ 
<span style="white-space:pre">              </span>continue; 
<span style="white-space:pre">          </span>} 
<span style="white-space:pre">          </span> 
<span style="white-space:pre">          </span>CString strName = mxc.szName; 
<span style="white-space:pre">          </span>strName.MakeUpper(); 
<span style="white-space:pre">          </span>if(-1 != strName.Find(_T("BOOST")) || 
<span style="white-space:pre">              </span>-1 != strName.Find(_T("麥克風加強")) || 
<span style="white-space:pre">              </span>-1 != strName.Find(_T("20DB"))) 
<span style="white-space:pre">          </span>{ 
<span style="white-space:pre">              </span>MIXERCONTROLDETAILS_BOOLEAN enh[2]; 
<span style="white-space:pre">              </span>MIXERCONTROLDETAILS<span style="white-space:pre">            </span>mxcd; 
<span style="white-space:pre">              </span>mxcd.cMultipleItems = 0; 
<span style="white-space:pre">              </span>mxcd.dwControlID<span style="white-space:pre">   </span>= mxc.dwControlID; 
<span style="white-space:pre">              </span>mxcd.cbStruct<span style="white-space:pre">      </span>= sizeof(MIXERCONTROLDETAILS); 
<span style="white-space:pre">              </span>mxcd.cbDetails<span style="white-space:pre">     </span>= sizeof(MIXERCONTROLDETAILS_BOOLEAN); 
<span style="white-space:pre">              </span>mxcd.paDetails<span style="white-space:pre">     </span>= enh; 
<span style="white-space:pre">              </span>mxcd.cChannels<span style="white-space:pre">     </span>= sub_line.cChannels; 
 
 
<span style="white-space:pre">              </span>if(MMSYSERR_NOERROR != mixerGetControlDetails((HMIXEROBJ)hMixer, &mxcd, MIXER_OBJECTF_HMIXER|MIXER_GETCONTROLDETAILSF_VALUE)) 
<span style="white-space:pre">              </span>{ 
<span style="white-space:pre">                  </span>ASSERT(false); 
<span style="white-space:pre">                  </span>break; 
<span style="white-space:pre">              </span>} 
<span style="white-space:pre">              </span>enh[0].fValue = enhance?1:0; 
<span style="white-space:pre">              </span>enh[1].fValue = enhance?1:0; 
<span style="white-space:pre">              </span>if(MMSYSERR_NOERROR != mixerSetControlDetails((HMIXEROBJ)hMixer, &mxcd, MIXER_OBJECTF_HMIXER|MIXER_SETCONTROLDETAILSF_VALUE)) 
<span style="white-space:pre">              </span>{ 
<span style="white-space:pre">                  </span>ASSERT(false); 
<span style="white-space:pre">                  </span>break; 
<span style="white-space:pre">              </span>} 
<span style="white-space:pre">              </span>result = true; 
<span style="white-space:pre">          </span>} 
<span style="white-space:pre">      </span>} 
<span style="white-space:pre">      </span>::mixerClose(hMixer); 
<span style="white-space:pre">      </span>hMixer = NULL; 
<span style="white-space:pre">  </span>} 
 
 
<span style="white-space:pre">  </span>return result; 

[cpp]
CMicrophoneEnhance microphoneEnhance; 
[cpp] view plaincopy
microphoneEnhance.SetEnhance(true, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS); 
[cpp]
microphoneEnhance.SetEnhance(true, MIXERLINE_COMPONENTTYPE_DST_WAVEIN) 
[cpp]
 
暫時只能通過枚舉方法,把所有"麥克風加強"的MIXLINE打開來實現,如果有更好的方法,歡迎指出!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved