線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:4467
推到 Plurk!
推到 Facebook!

如何控制音效卡

答題得分者是:axsoft
newken
一般會員


發表:26
回覆:52
積分:15
註冊:2003-03-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-06-26 17:06:08 IP:163.28.xxx.xxx 未訂閱
請問各位新進: 小弟想要控制音效卡,但不知如何下手,請問各位先進我該如何著手呢 謝謝
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-06-26 18:10:58 IP:61.218.xxx.xxx 未訂閱
引言: 請問各位新進: 小弟想要控制音效卡,但不知如何下手,請問各位先進我該如何著手呢 謝謝 < face="Verdana, Arial, Helvetica"> 您可以透過"WINMM.DLL"來控制您的音效卡,透過waveOutGetNumDevs()來偵測音效卡的狀態 http://developerfusion.com/show/264/ winmm.lib is an import library for winmm.dll. winmm.lib is in the lib directory of your C compiler normally. I am not sure what you need for C Builder. Check the C Builder documentations (multimedia section such as the PlaySound function, or the mixerOpen function). 這有個範例 http://www.codeguru.com/multimedia/ADMixer.shtml

Audio Mixer Functions Demo

<!-- Author and contact details -->This article was contributed by Chen Su.<!-- For which environment is this code specific??? -->
Environment: Visual C 6.0 with Service Pack 3, Windows 9x, Windows NT 4.0 with Service Pack 6a, and Windows 2000
Audio Mixer Functions are a set of functions that control the routing of audio lines to a destination device for playing or recording. They can also control volume and other effects. Although there are only ten functions and two messages in this API, some people feel it's a little difficult to use them because of the flexibility. Here I am going to present four simple programs to demonstrate how to use this powerful API. I kept these four programs as simple as possible and one program does one thing only so that you can understand them easily. I also tried to separate the actual operations from the user interface as much as possible. All the functions related to Audio Mixer Functions have the prefix "amd". I did not write C classes for those functions as the main purpose here is to give you a tutorial. To master this API, you may read the Platform SDK documentation on Audio Mixers and play around with these four programs. You may also wish to check out the Platform SDK Audio Sample Mixapp: Sample Mixer Application," which is not so easy to read.
To better understand Audio Mixer Functions, keep in mind the following key facts.
  • There are zero, one, or more audio mixer devices in a system.
  • Each audio mixer device has one or more destination audio lines.
  • Each destination audio line has zero, one, or more source audio lines associated with it.
  • Each (destination or source) audio line has zero, one, or more mixer controls associated with it. A mixer control can perform any number of functions (such as control volume), depending on the characteristics of the associated audio line.
All four programs are MFC dialog-based. For the sake of brevity, they always use the first mixer device if there is more than one mixer device present in the system. The mixerOpen function is called with the CALLBACK_WINDOW flag in the fdwOpen parameter and a window handle in the dwCallback parameter in Programs 1, 2, and 4 so that the MM_MIXM_CONTROL_CHANGE message can be received in order to refresh the state of the controls.

Program 1. Master Mute

<!-- Sample image - gif or jpg -->Master Mute
This program is equivalent to the "Mute all" check box of the Windows Volume Control for Playback. The Master Mute control is the MIXERCONTROL_CONTROLTYPE_MUTE control of the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination audio line. It belongs to the switch controls (MIXERCONTROL_CT_CLASS_SWITCH), which are two-state switches. It uses the MIXERCONTROLDETAILS_BOOLEAN structure to retrieve and set control properties. Whenever the check box is clicked, CMuteDlg::amdSetMasterMuteValue is called to set the Master Mute value accordingly. The MM_MIXM_CONTROL_CHANGE message is received once the state of the Master Mute control has changed. In this case, CMuteDlg::amdGetMasterMuteValue is called to retrieve the current value of the Master Mute control and update the state of the check box accordingly.
Download Program 1 - 77 Kb

Program 2. Master Volume

<!-- Sample image - gif or jpg -->Master Volume
This program is equivalent to the "Volume Control" trackbar of the Windows Volume Control for Playback. The Master Volume control is the MIXERCONTROL_CONTROLTYPE_VOLUME control of the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination audio line. It belongs to the fader controls (MIXERCONTROL_CT_CLASS_FADER), which have a linear scale. It uses the MIXERCONTROLDETAILS_UNSIGNED structure to retrieve and set control properties. Whenever the trackbar is clicked, CVolumeDlg::amdSetMasterVolumeValue is called to set the Master Volume value accordingly. The MM_MIXM_CONTROL_CHANGE message is received once the state of the Master Volume control has changed. In this case, CVolumeDlg::amdGetMasterVolumeValue is called to retrieve the current value of the Master Volume control and update the state of the trackbar accordingly.
Download Program 2 - 77 Kb

Program 3. Wave Meter

<!-- Sample image - gif or jpg -->Wave Meter
This program is equivalent to the "Wave Meter" control of the Windows Volume Control for Playback. The Wave Meter control is the MIXERCONTROL_CONTROLTYPE_PEAKMETER control of the MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT source audio line associated with the MIXERLINE_COMPONENTTYPE_DST_SPEAKERS destination audio line. It belongs to the meter controls (MIXERCONTROL_CT_CLASS_METER), which measure data passing through an audio line. It uses the MIXERCONTROLDETAILS_SIGNED structure to retrieve and set control properties. A timer is created to monitor the value of the Wave Meter control. CMeterDlg::amdGetWaveMeterValue is called to retrieve the current value of the Wave Meter control and update the state of the progress bar accordingly once a WM_TIMER message is received.
Run it and play a sound file using other applications; you can see it dancing. Note that the sound from MIDI or CD Audio is not reflected here because it passes through the MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER or MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC source audio lines respectively.
Download Program 3 - 76 Kb

Program 4. Microphone Select

<!-- Sample image - gif or jpg -->Microphone Select
This program is equivalent to the "Microphone Select" check box of the Windows Volume Control for Recording. The Microphone Select control is one of the items of the MIXERCONTROL_CONTROLTYPE_MIXER or MIXERCONTROL_CONTROLTYPE_MUX controls of the MIXERLINE_COMPONENTTYPE_DST_WAVEIN destination audio line. It belongs to the list controls (MIXERCONTROL_CT_CLASS_LIST), which provide single-select or multiple-select states for complex audio lines. It uses the MIXERCONTROLDETAILS_BOOLEAN structure to retrieve and set control properties. Whenever the check box is clicked, CSelectDlg::amdSetMicSelectValue is called to set the Microphone Select value accordingly. The MM_MIXM_CONTROL_CHANGE message is received once the state of the Microphone Select control has changed. In this case, CSelectDlg::amdGetMicSelectValue is called to retrieve the current value of the Microphone Select control and update the state of the check box accordingly.
Download Program 4 - 78 Kb

Happy programming and good luck!

History

Date Posted: May 27, 1998
Date Last Updated: October 25, 2000
HAVE A NICE DAY FOR YOU
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-06-26 18:19:15 IP:61.218.xxx.xxx 未訂閱
Platform SDK: Windows Multimedia    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmfunc_2ooj.asp

Multimedia Functions

The following functions are used with multimedia.
acmDriverAdd
acmDriverClose
acmDriverDetails
acmDriverEnum
acmDriverEnumCallback
acmDriverID
acmDriverMessage
acmDriverOpen
acmDriverPriority
acmDriverProc
acmDriverRemove
acmFilterChoose
acmFilterChooseHookProc
acmFilterDetails
acmFilterEnum
acmFilterEnumCallback
acmFilterTagDetails
acmFilterTagEnum
acmFilterTagEnumCallback
acmFormatChoose
acmFormatChooseHookProc
acmFormatDetails
acmFormatEnum
acmFormatEnumCallback
acmFormatSuggest
acmFormatTagDetails
acmFormatTagEnum
acmFormatTagEnumCallback
acmGetVersion
acmMetrics
acmStreamClose
acmStreamConvert
acmStreamConvertCallback
acmStreamMessage
acmStreamOpen
acmStreamPrepareHeader
acmStreamReset
acmStreamSize
acmStreamUnprepareHeader
auxGetDevCaps
auxGetNumDevs
auxGetVolume
auxOutMessage
auxSetVolume
AVIBuildFilter
AVIClearClipboard
AVIFileAddRef
AVIFileCreateStream
AVIFileEndRecord
AVIFileExit
AVIFileGetStream
AVIFileInfo
AVIFileInit
AVIFileOpen
AVIFileReadData
AVIFileRelease
AVIFileWriteData
AVIGetFromClipboard
AVIMakeCompressedStream
AVIMakeFileFromStreams
AVIMakeStreamFromClipboard
AVIPutFileOnClipboard
AVISave
AVISaveOptions
AVISaveOptionsFree
AVISaveV
AVIStreamAddRef
AVIStreamBeginStreaming
AVIStreamCreate
AVIStreamEndStreaming
AVIStreamFindSample
AVIStreamGetFrame
AVIStreamGetFrameClose
AVIStreamGetFrameOpen
AVIStreamInfo
AVIStreamLength
AVIStreamOpenFromFile
AVIStreamRead
AVIStreamReadData
AVIStreamReadFormat
AVIStreamReleaseAVIStreamSampleToTime
AVIStreamSetFormat
AVIStreamStart
AVIStreamTimeToSample
AVIStreamWrite
AVIStreamWriteData
capControlCallback
capCreateCaptureWindow
capErrorCallback
capGetDriverDescription
capStatusCallback
capVideoStreamCallback
capWaveStreamCallback
capYieldCallback
CreateEditableStream
DllGetClassObject
DrawDibBegin
DrawDibChangePalette
DrawDibClose
DrawDibDraw
DrawDibEnd
DrawDibGetBuffer
DrawDibGetPalette
DrawDibOpen
DrawDibProfileDisplay
DrawDibRealize
DrawDibSetPalette
DrawDibStart
DrawDibStop
DrawDibTime
EditStreamClone
EditStreamCopy
EditStreamCut
EditStreamPaste
EditStreamSetInfo
EditStreamSetName
GetOpenFileNamePreview
GetSaveFileNamePreview
ICClose
ICCompress
ICCompressorChoose
ICCompressorFree
ICDecompress
ICDecompressEx
ICDecompressExBegin
ICDecompressExQuery
ICDraw
ICDrawBegin
ICDrawSuggestFormat
ICGetDisplayFormat
ICGetInfo
ICImageCompress
ICImageDecompress
ICInfo
ICInstall
ICLocate
ICOpen
ICOpenFunction
ICRemove
ICSendMessage
ICSeqCompressFrame
ICSeqCompressFrameEnd
ICSeqCompressFrameStart
ICSetStatusProc
IOProc
joyConfigChanged
joyGetDevCaps
joyGetNumDevs
joyGetPos
joyGetPosEx
joyGetThreshold
joyReleaseCapture
joySetCapture
joySetThreshold
mciExecute
mciGetCreatorTask
mciGetDeviceID
mciGetDeviceIDFromElementID
mciGetErrorString
mciGetYieldProc
mciSendCommand
mciSendString
mciSetYieldProc
MCIWndCreate
MCIWndRegisterClass
midiConnect
midiDisconnect
midiInAddBuffer
midiInClose
midiInGetDevCaps
midiInGetErrorText
midiInGetID
midiInGetNumDevs
midiInMessage
midiInOpen
midiInPrepareHeader
midiInProc
midiInReset
midiInStart
midiInStop
midiInUnprepareHeader
midiOutCacheDrumPatches
midiOutCachePatches
midiOutClose
midiOutGetDevCaps
midiOutGetErrorText
midiOutGetID
midiOutGetNumDevs
midiOutGetVolume
midiOutLongMsg
midiOutMessage
midiOutOpen
midiOutPrepareHeader
MidiOutProc
midiOutReset
midiOutSetVolume
midiOutShortMsg
midiOutUnprepareHeader
midiStreamClose
midiStreamOpen
midiStreamOut
midiStreamPause
midiStreamPosition
midiStreamProperty
midiStreamRestart
midiStreamStop
mixerClose
mixerGetControlDetails
mixerGetDevCaps
mixerGetID
mixerGetLineControls
mixerGetLineInfo
mixerGetNumDevs
mixerMessage
mixerOpen
mixerSetControlDetails
mmioAdvance
mmioAscend
mmioClose
mmioCreateChunk
mmioDescend
mmioFlush
mmioGetInfo
mmioInstallIOProc
mmioOpen
MMIOProc
mmioRead
mmioRename
mmioSeek
mmioSendMessage
mmioSetBuffer
mmioSetInfo
mmioStringToFOURCC
mmioWrite
MyStatusProc
PlaySound
sndPlaySound
StretchDIB
timeBeginPeriod
timeEndPeriod
timeGetDevCaps
timeGetSystemTime
timeGetTime
timeKillEvent
TimeProc
timeSetEvent
waveInAddBuffer
waveInClose
waveInGetDevCaps
waveInGetErrorText
waveInGetID
waveInGetNumDevs
waveInGetPosition
waveInMessage
waveInOpen
waveInPrepareHeader
waveInProc
waveInReset
waveInStart
waveInStop
waveInUnprepareHeader
waveOutBreakLoop
waveOutClose
waveOutGetDevCaps
waveOutGetErrorText
waveOutGetID
waveOutGetNumDevs
waveOutGetPitch
waveOutGetPlaybackRate
waveOutGetPosition
waveOutGetVolume
waveOutMessage
waveOutOpen
waveOutPause
waveOutPrepareHeader
waveOutProc
waveOutReset
waveOutRestart
waveOutSetPitch
waveOutSetPlaybackRate
waveOutSetVolume
waveOutUnprepareHeader
waveOutWrite
HAVE A NICE DAY FOR YOU 發表人 - axsoft 於 2003/06/26 18:24:11
newken
一般會員


發表:26
回覆:52
積分:15
註冊:2003-03-26

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-07-14 13:08:43 IP:163.28.xxx.xxx 未訂閱
axsfot大哥你好: 像以上這些說明最主要是wave檔的IO部份,那如果我把wave檔存進一個buffer,然後要去做dsp的動作,譬如做convolution、fir filter這些處理,那我該如何進行下一步.................... 謝謝
系統時間:2024-04-29 5:54:42
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!