asvmfd
一般會員
發表:46 回覆:30 積分:15 註冊:2004-11-09
發送簡訊給我
|
請教各位, 做一個TrackBar來調,有看到Caption的值有變化,但是同時錄的聲音好像也沒變大聲...
是問題出在哪?
Thanks
如下程式擷錄自http://delphi.ktop.com.tw/topic.php?TOPIC_ID=60600
//--------------------------------------------------------------------------- #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TTrackBar *TrackBar1;
TTrackBar *TrackBar2;
TLabel *Label1; void __fastcall FormShow(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall TrackBar2Change(TObject *Sender);
private: // User declarations public: // User declarations
__fastcall TForm1(TComponent* Owner);
bool TForm1::SetMicrophoneVolume( unsigned int bValue );
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif void __fastcall TForm1::FormShow(TObject *Sender)
{
DWORD volume;
TrackBar1->Max = 0xFFFF;
TrackBar1->Frequency = 1000;
TrackBar2->Max = 0xFFFF;
TrackBar2->Frequency = 1000; TrackBar1->Position = waveOutGetVolume(0, &volume);
TrackBar1->Position = 0xFFFF - LOWORD(volume);
volume_org=volume;
} void __fastcall TForm1::TrackBar2Change(TObject *Sender)
{ int value = 0xFFFF - TrackBar2->Position;
//waveOutSetVolume(0, MAKELONG(0xFFFF - TrackBar1->Position, 0xFFFF - TrackBar1->Position));
//SetMicrophoneVolume(MAKELONG(0xFFFF - TrackBar2->Position);
SetMicrophoneVolume( value);
Label1->Caption=IntToStr(value);
} //設定 麥克風的音量 0 ~ 65535
bool TForm1::SetMicrophoneVolume(unsigned int bValue)
{
HMIXER hMix;
MIXERLINECONTROLS mxlc;
MIXERCONTROLDETAILS mxcd;
MIXERCONTROLDETAILS_UNSIGNED vol;
MIXERCONTROL mxc;
MIXERLINE mxl;
int intRet;
int nMixerDevs; // Check if Mixer is available
nMixerDevs = mixerGetNumDevs();
if (nMixerDevs < 1) return false; // open the mixer
intRet = mixerOpen(&hMix, 0, 0, 0, 0);
if (intRet != MMSYSERR_NOERROR) return false; try {
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
mxl.cbStruct = sizeof(mxl); // get line info
intRet = mixerGetLineInfo(hMix, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE); if (intRet == MMSYSERR_NOERROR) {
memset(&mxlc, 0, sizeof(mxlc));
mxlc.cbStruct = sizeof(mxlc);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(mxc); mxlc.pamxctrl = &mxc;
intRet = mixerGetLineControls(hMix, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); if (intRet == MMSYSERR_NOERROR) {
memset(&mxcd, 0, sizeof(mxcd));
mxcd.dwControlID = mxc.dwControlID;
mxcd.cbStruct = sizeof(mxcd);
mxcd.cMultipleItems = 0;
mxcd.cbDetails = sizeof(vol);
mxcd.paDetails = &vol;
mxcd.cChannels = 1; // vol.dwValue = mxlc.pamxctrl.Bounds.lMinimum; Set min. Volume / Minimum setzen
// vol.dwValue = mxlc.pamxctrl.Bounds.lMaximum; Set max. Volume / Maximum setzen
vol.dwValue = bValue; intRet = mixerSetControlDetails(hMix, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
if (intRet != MMSYSERR_NOERROR) {
intRet = mixerClose(hMix);
throw new Exception("SetControlDetails Error");
}
}
}
else {
intRet = mixerClose(hMix);
throw new Exception("SetControlDetails Error");
}
}
catch (...) {
return false;
} intRet = mixerClose(hMix);
return true;
}
|
allenchan
資深會員
發表:10 回覆:306 積分:283 註冊:2004-01-06
發送簡訊給我
|
以下這篇文章所調整的是播放的麥克風音量:
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=60600 我另外寫了一個調整錄音的,請試試看:
void SetMicVolume(unsigned int iValue)
{
// Open the mixer device
HMIXER hmx;
mixerOpen(&hmx, 0, 0, 0, 0); // Get the line info for the wave in destination line
MIXERLINE mxl;
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mixerGetLineInfo((HMIXEROBJ)hmx, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE); // Now find the microphone source line connected to this wave in destination
DWORD cConnections = mxl.cConnections;
for (DWORD j = 0; j < cConnections; j )
{
mxl.dwSource = j;
mixerGetLineInfo((HMIXEROBJ)hmx, &mxl, MIXER_GETLINEINFOF_SOURCE);
if (MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE == mxl.dwComponentType)
break;
}
// Find a volume control, if any, of the microphone line
MIXERCONTROL mxc;
MIXERLINECONTROLS mxlc;
memset(&mxlc, 0, sizeof(MIXERLINECONTROLS));
mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlID = MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
mxlc.pamxctrl = &mxc;
if(!mixerGetLineControls((HMIXEROBJ)hmx, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)){
// Found!
DWORD cChannels = mxl.cChannels;
if (MIXERCONTROL_CONTROLF_UNIFORM & mxc.fdwControl)
cChannels = 1; MIXERCONTROLDETAILS_UNSIGNED vol; MIXERCONTROLDETAILS mxcd;
memset(&mxcd, 0, sizeof(MIXERCONTROLDETAILS));
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mxcd.dwControlID = mxc.dwControlID;
mxcd.cChannels = cChannels;
mxcd.cMultipleItems = 0;
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mxcd.paDetails = &vol; vol.dwValue = iValue; mixerSetControlDetails((HMIXEROBJ)hmx, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
}
mixerClose(hmx);
}
|
asvmfd
一般會員
發表:46 回覆:30 積分:15 註冊:2004-11-09
發送簡訊給我
|
那我去試試先,
請問這對Line in 與 Microphone效果會一樣?
請高手指點.
謝謝
|
allenchan
資深會員
發表:10 回覆:306 積分:283 註冊:2004-01-06
發送簡訊給我
|
您好,這個 Function 是寫來調整錄音的麥克風音量用的 Sample,您的主題不是要問如何調整輸入的"麥克風音量"嗎? 發表人 - allenchan 於 2004/12/03 20:40:01
|
asvmfd
一般會員
發表:46 回覆:30 積分:15 註冊:2004-11-09
發送簡訊給我
|
不好意思,我的意思是說麥克風插在Mic的地方與麥克風插在Line in的地方是否都可用這支程式?
要找個有Lin in的板子來試試前先請教一番...
奇怪,這板子看不到Line in..
|
allenchan
資深會員
發表:10 回覆:306 積分:283 註冊:2004-01-06
發送簡訊給我
|
我想是不行,您試試看吧 ~~ 你試試把右下角喇叭圖案點兩下,選項 -> 內容 -> 錄音,選擇
|
asvmfd
一般會員
發表:46 回覆:30 積分:15 註冊:2004-11-09
發送簡訊給我
|
選項 -> 內容 -> 錄音->看不到Line in.
會找個有Lin in的板子來試試...
謝謝先,
|