音量控制问题:

Gujianda 2004-07-22 03:37:23
看了[fuanwei(草原上狂奔的蜗牛)]贴的代码,调试了一下,不错!
但是,下面这个结构:
Private Type MIXERCONTROL
cbStruct As Long
dwControlID As Long
dwControlType As Long
fdwControl As Long
cMultipleItems As Long
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
lMinimum As Long
lMaximum As Long
reserved(10) As Long
End Type

明明在 fGetVolumeControl 过程中用来接受设备信息
却不能获得设备的当前音量,不懂!
有哪位大虾能再说明说明?
...全文
288 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
HenryXiaoY 2004-08-01
  • 打赏
  • 举报
回复
up
SafeF8 2004-07-30
  • 打赏
  • 举报
回复
声道控制:
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Public Declare Function mciGetDeviceID Lib "winmm.dll" Alias "mciGetDeviceIDA" (ByVal lpstrName As String) As Long

Public Declare Function waveOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Enum PlayTypeName
File = 1
CDAudio = 2
VCD = 3
RealPlay = 4
End Enum
Dim PlayType As PlayTypeName
Enum AudioSource
AudioStereo = 0 ' "stereo"
AudioLeft = 1 '"left"
AudioRight = 2 '"right"
End Enum
Dim hWndMusic As Long
Dim prevWndproc As Long

'======================================================
'设置声道
'======================================================
Public Function SetAudioSource(sAudioSource As AudioSource) As Boolean
Dim RefInt As Long
Dim strSource As String
Select Case sAudioSource
Case 1: strSource = "left"
Case 2: strSource = "right"
Case 0: strSource = "stereo"
End Select
SetAudioSource = False
RefInt = mciSendString("setaudio NOWMUSIC source to " & strSource, vbNull, 0, 0)
If RefInt = 0 Then SetAudioSource = True
End Function

http://blog.csdn.net/safef8/archive/2004/07/21/47544.aspx

Fancly 2004-07-27
  • 打赏
  • 举报
回复
mark
liuyan4794 2004-07-24
  • 打赏
  • 举报
回复
音量本来就是由左右两个控制,如果将音量的channels设置为1,则认为是左右声道的音量相等(双声道);如果将音量的channels设置为2,设置是需要设置两个声道的音量,将一个声道的音量设置为0,则只有另外一个声道发声音
Gujianda 2004-07-23
  • 打赏
  • 举报
回复
大恩不言报!谢谢!
已经很全面了,但人是贪得无厌的:)
再请问:在你的类里左右声道如何控制?
pcwak 2004-07-22
  • 打赏
  • 举报
回复
接上面:
Private Function GetMixerControl(ByVal hMixer&, ByVal componentType&, _
mxc As MIXERCONTROL, ByVal cType&) As Boolean
Dim ctrlType&, infoType&

Select Case cType
Case 1: ctrlType = MIXERCONTROL_CONTROLTYPE_VOLUME '# search for volume controls
infoType = MIXER_GETLINEINFOF_COMPONENTTYPE
Case 2: ctrlType = MIXERCONTROL_CONTROLTYPE_MUTE '# search for mute controls
infoType = MIXER_GETLINEINFOF_LINEID
'... To be extended
Case Else: GetMixerControl = False: Exit Function
End Select


mxl.cbStruct = Len(mxl)
mxl.dwComponentType = componentType

'# Obtain a line corresponding to the component Private Type
rc = mixerGetLineInfo(hMixer, mxl, infoType)

If (MMSYSERR_NOERROR = rc) Then
With mxlc
.cbStruct = Len(mxlc)
.dwLineID = mxl.dwLineID
.dwControl = ctrlType
.cControls = 1
.cbmxctrl = Len(mxc)

'# Allocate a buffer for the control
hmem = GlobalAlloc(&H40, Len(mxc))
.pamxctrl = GlobalLock(hmem)
mxc.cbStruct = Len(mxc)
End With
'# Get the control
rc = mixerGetLineControls(hMixer, mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)

If (MMSYSERR_NOERROR = rc) Then
GetMixerControl = True
'# Copy the control into the destination structure
CopyStructFromPtr mxc, mxlc.pamxctrl, Len(mxc)
Else
GetMixerControl = False
End If

Call GlobalFree(hmem)
Exit Function
End If

GetMixerControl = False
End Function

'********************************************************************************
'# This Function sets the value for a mixer control. Returns True if successful

Private Function SetValue(mxctl As MIXERCONTROL, ByVal volume&) As Boolean

mxc = mxctl
Call PrepareStruct

'# Copy the data into the control value buffer
Struct.dwValue = volume
CopyPtrFromStruct mxcd.paDetails, Struct, Len(Struct)

'# Set the control value
rc = mixerSetControlDetails(hMixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
GlobalFree (hmem)

If (rc = MMSYSERR_NOERROR) Then
SetValue = True
Else
SetValue = False
End If
End Function

'********************************************************************************
'# Diese Funktion gibt den aktuell eingestellten Wert
'# f黵 das an die Funktion 黚ergebene MixerControl zur點k
'# This function returns the current value of the passed mixercontrol

Private Function GetValue&(mxctl As MIXERCONTROL)

mxc = mxctl
Call PrepareStruct

'# Get the control value
rc = mixerGetControlDetails(hMixer, mxcd, MIXER_GETCONTROLDETAILSF_VALUE)

'# Copy the data from control value buffer
CopyStructFromPtr Struct, mxcd.paDetails, Len(Struct)
Call GlobalFree(hmem)

If (rc = MMSYSERR_NOERROR) Then
GetValue = Struct.dwValue '# Aktuell eingestellter Wert / Current value
Else
GetValue = 0
End If
End Function

'********************************************************************************
'# Initialisieren der MIXERCONTROLDETAILS-Struktur
'# Initialize the MIXERCONTROLDETAILS structure
Private Sub PrepareStruct()

Struct.dwValue = 0
With mxcd
.item = 0
.dwControlID = mxc.dwControlID
.cbStruct = Len(mxcd)
.cbDetails = Len(Struct)
'# Allocate a buffer for the control value buffer
hmem = GlobalAlloc(&H40, Len(Struct))
.paDetails = GlobalLock(hmem)
.cChannels = 1
End With
End Sub

'********************************************************************************
Private Sub Class_Terminate()
'# Close the mixer to free the memory
Call mixerClose(hMixer)
End Sub

'********************************************************************************

窗体代码:
Private Sub Command1_Click()
Dim cVolume As New clsVolume
If cVolume.WaveMute = 0 Then
MsgBox "系统音量:" & cVolume.WaveVolume
Else
MsgBox "静音"
End If
End Sub
pcwak 2004-07-22
  • 打赏
  • 举报
回复
接上面:
Friend Function IsCtrl(ByVal Index&) As Boolean '# True, wenn Control vorhanden
IsCtrl = CtrlState And Index '# True, when control exists
End Function
'--------------------------------------------------------------------------------
Friend Function IsMute(ByVal Index&) As Boolean '# True, wenn Control vorhanden
IsMute = MuteState And Index '# True, when control exists
End Function

'********************************************************************************
'********************************************************************************
'# Hier werden die Grundparameter abgefragt bzw. gesetzt
'# Here the the fundamental parameters are determined rsp. set
Private Sub Class_Initialize()
'---------------------------------------------------------------------
'# Open the mixer with deviceID 0.
rc = mixerOpen(hMixer, 0, 0, 0, 0)
If rc <> MMSYSERR_NOERROR Then
MsgBox "No mixer found!"
Exit Sub
End If
'---------------------------------------------------------------------
'# Get the waveout volume control (Gesamtlautst鋜ke/main volume)
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, volCtrl, 1)
If bOK Then
'# If the Function successfully gets the volume control, the maximum
'# and minimum values are specified by lMaximum and lMinimum
CtrlState = CtrlState Or 1
With volCtrl
MinVolVol = .lMinimum
MaxVolVol = .lMaximum
End With
'# Get the waveout mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, volMute, 2)
If bOK Then MuteState = MuteState Or 1
End If
'---------------------------------------------------------------------
'# Get the microphone volume control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, micCtrl, 1)
If bOK Then
CtrlState = CtrlState Or 2
With micCtrl
MinMicVol = .lMinimum
MaxMicVol = .lMaximum
End With
'# Get the microphone mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, micMute, 2)
If bOK Then MuteState = MuteState Or 2
End If
'---------------------------------------------------------------------
'# Get the wave-in volume control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, wavCtrl, 1)
If bOK Then
CtrlState = CtrlState Or 4
With wavCtrl
MinWavVol = .lMinimum
MaxWavVol = .lMaximum
End With
'# Get the wave-in mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, wavMute, 2)
If bOK Then MuteState = MuteState Or 4
End If
'---------------------------------------------------------------------
'# Get the line-in volume control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_LINE, linCtrl, 1)
If bOK Then
CtrlState = CtrlState Or 8
With linCtrl
MinLinVol = .lMinimum
MaxLinVol = .lMaximum
End With
'# Get the line-in mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_LINE, linMute, 2)
If bOK Then MuteState = MuteState Or 8
Else '# Some manufacturer use this type of device for line-in
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY, linCtrl, 1)
If bOK Then
CtrlState = CtrlState Or 8
With linCtrl
MinLinVol = .lMinimum
MaxLinVol = .lMaximum
End With
'# Get the line-in mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY, linMute, 2)
If bOK Then MuteState = MuteState Or 8
End If
End If
'---------------------------------------------------------------------
'# Get the CD audio volume control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC, cd_Ctrl, 1)
If bOK Then
CtrlState = CtrlState Or 16
With cd_Ctrl
MinCD_Vol = .lMinimum
MaxCD_Vol = .lMaximum
End With
'# Get the CD audio mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC, cdrMute, 2)
If bOK Then MuteState = MuteState Or 16
End If
'---------------------------------------------------------------------
'# Get the MIDI volume control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER, midCtrl, 1)
If bOK Then
CtrlState = CtrlState Or 32
With midCtrl
MinMidVol = .lMinimum
MaxMidVol = .lMaximum
End With
'# Get the MIDI mute control
bOK = GetMixerControl(hMixer, MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER, midMute, 2)
If bOK Then MuteState = MuteState Or 32
End If
'Debug.Print CtrlState
'Debug.Print MuteState
'---------------------------------------------------------------------
'# In the same way may be opened other devices;
'# for possible types refere to the constants
'# MIXERLINE_COMPONENTTYPE_SRC_XXX and
'# MIXERLINE_COMPONENTTYPE_DST_XXX
'---------------------------------------------------------------------
End Sub
pcwak 2004-07-22
  • 打赏
  • 举报
回复
接上面:
Public Property Get MaxCDVolume&() '# Maximalwert der CD-Lautst鋜ke
MaxCDVolume = MaxCD_Vol '# Maximum value of CD volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MinMidVolume&() '# Minimalwert der MIDI-Lautst鋜ke
MinMidVolume = MinMidVol '# Minium value of MIDI volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MaxMidVolume&() '# Maximalwert der MIDI-Lautst鋜ke
MaxMidVolume = MaxMidVol '# Maximum value of MIDI volume
End Property
'--------------------------------------------------------------------------------
'# Current values
'--------------------------------------------------------------------------------
Public Property Get WaveVolume&() '# Aktuelle Gesamtlautst鋜ke
WaveVolume = GetValue(volCtrl) '# Current value of main volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MicroVolume&() '# Aktuelle Mikrofonlautst鋜ke
MicroVolume = GetValue(micCtrl) '# Current value of micro volume
End Property
'--------------------------------------------------------------------------------
Public Property Get WaveInVolume&() '# Aktuelle WaveIn-Lautst鋜ke
WaveInVolume = GetValue(wavCtrl) '# Current value of wave in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get LineInVolume&() '# Aktuelle LineIn-Lautst鋜ke
LineInVolume = GetValue(linCtrl) '# Current value of line in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get CD_Volume&() '# Aktuelle CD-Lautst鋜ke
CD_Volume = GetValue(cd_Ctrl) '# Current value of CD volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MIDIVolume&() '# Aktuelle MIDI-Lautst鋜ke
MIDIVolume = GetValue(midCtrl) '# Current value of MIDI volume
End Property
'--------------------------------------------------------------------------------
'# Mute Values
'--------------------------------------------------------------------------------
Public Property Get WaveMute&() '# Mute-Status der Gesamtlautst鋜ke
WaveMute = GetValue(volMute) '# Mute State of main volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MicroMute&() '# Mute-Status der Mikrofonlautst鋜ke
MicroMute = GetValue(micMute) '# Mute State of micro volume
End Property
'--------------------------------------------------------------------------------
Public Property Get WaveInMute&() '# Mute-Status der WaveIn-Lautst鋜ke
WaveInMute = GetValue(wavMute) '# Mute State of wave in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get LineInMute&() '# Mute-Status der LineIn-Lautst鋜ke
LineInMute = GetValue(linMute) '# Mute State of line in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get CD_Mute&() '# Mute-Status der CD-Lautst鋜ke
CD_Mute = GetValue(cdrMute) '# Mute State of CD volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MIDIMute&() '# Mute-Status der MIDI-Lautst鋜ke
MIDIMute = GetValue(midMute) '# Mute State of MIDI volume
End Property
'********************************************************************************
'# Volume Settings
'--------------------------------------------------------------------------------
Public Property Let WaveVolume(ByVal NewVolume&) '# Einstellung Gesamtlautst鋜ke
If NewVolume < MinVolVol Then NewVolume = MinVolVol '# Set main volume
If NewVolume > MaxVolVol Then NewVolume = MaxVolVol
Call SetValue(volCtrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
Public Property Let MicroVolume(ByVal NewVolume&) '# Einstellung Mikro-Lautst鋜ke
If NewVolume < MinMicVol Then NewVolume = MinMicVol '# Set micro volume
If NewVolume > MaxMicVol Then NewVolume = MaxMicVol
Call SetValue(micCtrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
Public Property Let WaveInVolume(ByVal NewVolume&) '# Einstellung Wave-Lautst鋜ke
If NewVolume < MinWavVol Then NewVolume = MinWavVol '# Set wave in volume
If NewVolume > MaxWavVol Then NewVolume = MaxWavVol
Call SetValue(wavCtrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
Public Property Let LineInVolume(ByVal NewVolume&) '# Einstellung Line-Lautst鋜ke
If NewVolume < MinLinVol Then NewVolume = MinLinVol '# Set line in volume
If NewVolume > MaxLinVol Then NewVolume = MaxLinVol
Call SetValue(linCtrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
Public Property Let CD_Volume(ByVal NewVolume&) '# Einstellung CD-Lautst鋜ke
If NewVolume < MinCD_Vol Then NewVolume = MinCD_Vol '# Set CD volume
If NewVolume > MaxCD_Vol Then NewVolume = MaxCD_Vol
Call SetValue(cd_Ctrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
Public Property Let MIDIVolume(ByVal NewVolume&) '# Einstellung MIDI Lautst鋜ke
If NewVolume < MinMidVol Then NewVolume = MinMidVol '# Set MIDI volume
If NewVolume > MaxMidVol Then NewVolume = MaxMidVol
Call SetValue(midCtrl, NewVolume)
End Property
'--------------------------------------------------------------------------------
'# Mute Settings
'--------------------------------------------------------------------------------
Public Property Let WaveMute(ByVal NewValue&) '# Mute-Status der Gesamtlautst鋜ke setzen
Call SetValue(volMute, NewValue) '# Set Mute State of main volume
End Property
'--------------------------------------------------------------------------------
Public Property Let MicroMute(ByVal NewValue&) '# Mute-Status der Mikrofonlautst鋜ke setzen
Call SetValue(micMute, NewValue) '# Set Mute State of micro volume
End Property
'--------------------------------------------------------------------------------
Public Property Let WaveInMute(ByVal NewValue&) '# Mute-Status der WaveInlautst鋜ke setzen
Call SetValue(wavMute, NewValue) '# Set Mute State of wave in volume
End Property
'--------------------------------------------------------------------------------
Public Property Let LineInMute(ByVal NewValue&) '# Mute-Status der LineInlautst鋜ke setzen
Call SetValue(linMute, NewValue) '# Set Mute State of line in Volume
End Property
'--------------------------------------------------------------------------------
Public Property Let CD_Mute(ByVal NewValue&) '# Mute-Status der CD-Lautst鋜ke setzen
Call SetValue(cdrMute, NewValue) '# Set Mute State of CD volume
End Property
'--------------------------------------------------------------------------------
Public Property Let MIDIMute(ByVal NewValue&) '# Mute-Status der MIDI-Lautst鋜ke setzen
Call SetValue(midMute, NewValue) '# Set Mute State of MIDI volume
End Property
pcwak 2004-07-22
  • 打赏
  • 举报
回复
接上面:
Private Declare Function mixerClose& Lib "winmm.dll" (ByVal hmx&)
Private Declare Function mixerGetControlDetails& Lib "winmm.dll" Alias "mixerGetControlDetailsA" _
(ByVal hmxobj&, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails&)
Private Declare Function mixerGetDevCaps& Lib "winmm.dll" Alias "mixerGetDevCapsA" (ByVal uMxId&, _
ByVal pmxcaps As MIXERCAPS, ByVal cbmxcaps&)
Private Declare Function mixerGetID& Lib "winmm.dll" (ByVal hmxobj&, pumxID&, ByVal fdwId&)
Private Declare Function mixerGetLineControls& Lib "winmm.dll" Alias "mixerGetLineControlsA" _
(ByVal hmxobj&, pmxlc As MIXERLINECONTROLS, ByVal fdwControls&)
Private Declare Function mixerGetLineInfo& Lib "winmm.dll" Alias "mixerGetLineInfoA" _
(ByVal hmxobj&, pmxl As MIXERLINE, ByVal fdwInfo&)
Private Declare Function mixerGetNumDevs& Lib "winmm.dll" ()
Private Declare Function mixerMessage& Lib "winmm.dll" (ByVal hmx&, ByVal uMsg&, _
ByVal dwParam1&, ByVal dwParam2&)
Private Declare Function mixerOpen& Lib "winmm.dll" (phmx&, ByVal uMxId&, _
ByVal dwCallback&, ByVal dwInstance&, ByVal fdwOpen&)
Private Declare Function mixerSetControlDetails& Lib "winmm.dll" (ByVal hmxobj&, _
pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails&)
Private Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
(Struct As Any, ByVal ptr&, ByVal cb&)
Private Declare Sub CopyPtrFromStruct Lib "kernel32" Alias "RtlMoveMemory" _
(ByVal ptr&, Struct As Any, ByVal cb&)
Private Declare Function GlobalAlloc& Lib "kernel32" (ByVal wFlags&, ByVal dwBytes&)
Private Declare Function GlobalLock& Lib "kernel32" (ByVal hmem&)
Private Declare Function GlobalFree& Lib "kernel32" (ByVal hmem&)
'********************************************************************************
Dim hMixer& '# mixer handle
Dim volCtrl As MIXERCONTROL '# waveout volume control (main volume)
Dim micCtrl As MIXERCONTROL '# microphone volume control
Dim wavCtrl As MIXERCONTROL '# wave-in volume control
Dim linCtrl As MIXERCONTROL '# line-in volume control
Dim cd_Ctrl As MIXERCONTROL '# audio-cd volume control
Dim midCtrl As MIXERCONTROL '# MIDI volume control
Dim auxCtrl As MIXERCONTROL '# aux volume control

Dim volMute As MIXERCONTROL '# waveout mute control (main volume)
Dim micMute As MIXERCONTROL '# microphone mute control
Dim wavMute As MIXERCONTROL '# wave-in mute control
Dim linMute As MIXERCONTROL '# line-in mute control
Dim cdrMute As MIXERCONTROL '# audio-cd mute control
Dim midMute As MIXERCONTROL '# MIDI mute control
Dim auxMute As MIXERCONTROL '# aux mute control

Dim MinVolVol&, MaxVolVol& '# Min/Max values for VolControl
Dim MinMicVol&, MaxMicVol& '# Min/Max values for MicroControl
Dim MinWavVol&, MaxWavVol& '# Min/Max values for WaveControl
Dim MinLinVol&, MaxLinVol& '# Min/Max values for LineControl
Dim MinCD_Vol&, MaxCD_Vol& '# Min/Max values for CD Control
Dim MinMidVol&, MaxMidVol& '# Min/Max values for MIDI
Dim MinAuxVol&, MaxAuxVol& '# Min/Max values for Aux

Dim mxl As MIXERLINE
Dim mxc As MIXERCONTROL
Dim mxcd As MIXERCONTROLDETAILS
Dim mxlc As MIXERLINECONTROLS
Dim Struct As MIXERCONTROLDETAILS_UNSIGNED

Dim bOK As Boolean '# boolean return code
Dim hmem& '# Memory handle
Dim rc& '# return code
Dim CtrlState& '# 1=Main; 2=Micro; 4=Wave; 8=Line; 16=CD; 32=MIDI
Dim MuteState& '# 1=Main; 2=Micro; 4=Wave; 8=Line; 16=CD; 32=MIDI
'********************************************************************************
'********************************************************************************
'# Hier folgt die "Schnittstelle" des Klassenmoduls nach au遝n
'# Here the class module "interface" follows
'********************************************************************************
'# Limits of the values
'--------------------------------------------------------------------------------
Public Property Get MinWaveVolume&() '# Minimalwert der Gesamtlautst鋜ke
MinWaveVolume = MinVolVol '# Minium value of main volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MaxWaveVolume&() '# Maximalwert der Gesamtlautst鋜ke
MaxWaveVolume = MaxVolVol '# Maximum value of main volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MinMicVolume&() '# Minimalwert der Mikrolautst鋜ke
MinMicVolume = MinMicVol '# Minium value of micro volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MaxMicVolume&() '# Maximalwert der Mikrolautst鋜ke
MaxMicVolume = MaxMicVol '# Maximum value of micro volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MinWavInVolume&() '# Minimalwert der WaveInlautst鋜ke
MinWavInVolume = MinWavVol '# Minium value of wave in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MaxWavInVolume&() '# Maximalwert der WaveInlautst鋜ke
MaxWavInVolume = MaxWavVol '# Maximum value of wave in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MinLineInVolume&() '# Minimalwert der LineInlautst鋜ke
MinLineInVolume = MinLinVol '# Minium value of line in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MaxLineInVolume&() '# Maximalwert der LineInlautst鋜ke
MaxLineInVolume = MaxLinVol '# Maximum value of line in volume
End Property
'--------------------------------------------------------------------------------
Public Property Get MinCDVolume&() '# Minimalwert der CD-Lautst鋜ke
MinCDVolume = MinCD_Vol '# Minium value of CD volume
End Property
pcwak 2004-07-22
  • 打赏
  • 举报
回复
类模块代码:
Option Explicit
'*******************************************************************************
Private Const MMSYSERR_NOERROR& = 0
Private Const MAXPNAMELEN& = 32
Private Const MIXER_LONG_NAME_CHARS& = 64
Private Const MIXER_SHORT_NAME_CHARS& = 16
Private Const MIXER_GETLINEINFOF_LINEID& = &H2
Private Const MIXER_GETLINEINFOF_COMPONENTTYPE& = &H3&
Private Const MIXER_GETCONTROLDETAILSF_VALUE& = &H0&
Private Const MIXER_GETCONTROLDETAILSF_LISTTEXT& = &H1&
Private Const MIXER_GETLINECONTROLSF_ONEBYID& = &H1
Private Const MIXER_GETLINECONTROLSF_ONEBYTYPE& = &H2&
Private Const MIXER_OBJECTF_WAVEOUT& = &H10000000
Private Const MIXER_SETCONTROLDETAILSF_VALUE& = &H0&
'--------------------------------------------------------------------------------
Private Const MIXERCONTROL_CT_CLASS_FADER& = &H50000000
Private Const MIXERCONTROL_CT_CLASS_SWITCH = &H20000000
Private Const MIXERCONTROL_CT_UNITS_BOOLEAN = &H10000
Private Const MIXERCONTROL_CT_UNITS_UNSIGNED& = &H30000
Private Const MIXERCONTROL_CONTROLTYPE_FADER& = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Private Const MIXERCONTROL_CONTROLTYPE_VOLUME& = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
Private Const MIXERCONTROL_CONTROLTYPE_BASS& = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
Private Const MIXERCONTROL_CONTROLTYPE_TREBLE& = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
Private Const MIXERCONTROL_CONTROLTYPE_EQUALIZER& = (MIXERCONTROL_CONTROLTYPE_FADER + 4)
Private Const MIXERCONTROL_CONTROLTYPE_BOOLEAN = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Private Const MIXERCONTROL_CONTROLTYPE_MUTE = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
'--------------------------------------------------------------------------------
Private Const MIXERLINE_COMPONENTTYPE_SRC_FIRST& = &H1000&
Private Const MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0)
Private Const MIXERLINE_COMPONENTTYPE_SRC_DIGITAL& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
Private Const MIXERLINE_COMPONENTTYPE_SRC_LINE& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Private Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Private Const MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
Private Const MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
Private Const MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
Private Const MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
Private Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
Private Const MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
Private Const MIXERLINE_COMPONENTTYPE_SRC_ANALOG& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
Private Const MIXERLINE_COMPONENTTYPE_SRC_LAST& = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
'--------------------------------------------------------------------------------
Private Const MIXERLINE_COMPONENTTYPE_DST_FIRST& = &H0&
Private Const MIXERLINE_COMPONENTTYPE_DST_UNDEFINED& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
Private Const MIXERLINE_COMPONENTTYPE_DST_DIGITAL& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
Private Const MIXERLINE_COMPONENTTYPE_DST_LINE& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
Private Const MIXERLINE_COMPONENTTYPE_DST_MONITOR& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
Private Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Private Const MIXERLINE_COMPONENTTYPE_DST_HEADPHONES& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
Private Const MIXERLINE_COMPONENTTYPE_DST_TELEPHONE& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
Private Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
Private Const MIXERLINE_COMPONENTTYPE_DST_VOICEIN& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
Private Const MIXERLINE_COMPONENTTYPE_DST_LAST& = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
'********************************************************************************
Private Type MIXERCAPS
wMid As Integer '# manufacturer id
wPid As Integer '# product id
vDriverVersion As Long '# version of the driver
szPname As String * MAXPNAMELEN '# product name
fdwSupport As Long '# misc. support bits
cDestinations As Long '# count of destinations
End Type
'--------------------------------------------------------------------------------
Private Type MIXERCONTROL
cbStruct As Long '# size in Byte of MIXERCONTROL
dwControlID As Long '# unique control id for mixer device
dwControlType As Long '# MIXERCONTROL_CONTROLTYPE_xxx
fdwControl As Long '# MIXERCONTROL_CONTROLF_xxx
cMultipleItems As Long '# if MIXERCONTROL_CONTROLF_MULTIPLE set
szShortName As String * MIXER_SHORT_NAME_CHARS '# short name of control
szName As String * MIXER_LONG_NAME_CHARS '# long name of control
lMinimum As Long '# Minimum value
lMaximum As Long '# Maximum value
reserved(10) As Long '# reserved structure space
End Type
'--------------------------------------------------------------------------------
Private Type MIXERCONTROLDETAILS
cbStruct As Long '# size in Byte of MIXERCONTROLDETAILS
dwControlID As Long '# control id to get/set details on
cChannels As Long '# number of channels in paDetails array
item As Long '# hwndOwner or cMultipleItems
cbDetails As Long '# size of _one_ details_XX struct
paDetails As Long '# pointer to array of details_XX structs
End Type
'--------------------------------------------------------------------------------
Private Type MIXERCONTROLDETAILS_UNSIGNED
dwValue As Long '# value of the control
End Type
'--------------------------------------------------------------------------------
Private Type MIXERLINE
cbStruct As Long '# size of MIXERLINE structure
dwDestination As Long '# zero based destination index
dwSource As Long '# zero based source index (if source)
dwLineID As Long '# unique line id for mixer device
fdwLine As Long '# state/information about line
dwUser As Long '# driver specific information
dwComponentType As Long '# component Private Type line connects to
cChannels As Long '# number of channels line supports
cConnections As Long '# number of connections (possible)
cControls As Long '# number of controls at this line
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
dwType As Long
dwDeviceID As Long
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
End Type
'--------------------------------------------------------------------------------
Private Type MIXERLINECONTROLS
cbStruct As Long '# size in Byte of MIXERLINECONTROLS
dwLineID As Long '# line id (from MIXERLINE.dwLineID)
'# MIXER_GETLINECONTROLSF_ONEBYID or
dwControl As Long '# MIXER_GETLINECONTROLSF_ONEBYTYPE
cControls As Long '# count of controls pamxctrl points to
cbmxctrl As Long '# size in Byte of _one_ MIXERCONTROL
pamxctrl As Long '# pointer to first MIXERCONTROL array
End Type
'********************************************************************************

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧