【VB开源代码栏目提醒】:网学会员--在 VB开源代码编辑为广大网友搜集整理了:音量与声道控制.frm绩等信息,祝愿广大网友取得需要的信息,参考学习。
VERSION 5.00
Begin VB.Form Form1
Caption = "可调音量与声道"
ClientHeight = 2790
ClientLeft = 60
ClientTop = 345
ClientWidth = 4425
LinkTopic = "Form1"
ScaleHeight = 2790
ScaleWidth = 4425
StartUpPosition = 3 '窗口缺省
Begin VB.HScrollBar pan
Height = 255
Left = 600
Max = 5000
Min = -5000
SmallChange = 30
TabIndex = 4
Top = 1920
Width = 3000
End
Begin VB.HScrollBar volume
Height = 255
Left = 600
Max = 0
Min = -5000
SmallChange = 30
TabIndex = 3
Top = 1080
Width = 3000
End
Begin VB.CommandButton pause
Caption = "暂停"
Height = 375
Left = 3000
TabIndex = 2
Top = 120
Width = 1215
End
Begin VB.CommandButton play
Caption = "播放"
Height = 375
Left = 1560
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.CommandButton stop
Caption = "停止"
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Label Label6
Caption = "右"
Height = 375
Left = 3840
TabIndex = 10
Top = 1920
Width = 375
End
Begin
VB.Label Label5
Caption = "左"
Height = 375
Left = 240
TabIndex = 9
Top = 1920
Width = 375
End
Begin VB.Label Label4
Caption = "大"
Height = 375
Left = 3840
TabIndex = 8
Top = 1080
Width = 375
End
Begin VB.Label Label3
Caption = "小"
Height = 375
Left = 240
TabIndex = 7
Top = 1080
Width = 375
End
Begin VB.Label Label2
Caption = "左右声道"
Height = 255
Left = 1800
TabIndex = 6
Top = 1560
Width = 975
End
Begin VB.Label Label1
Caption = "音量大小"
Height = 375
Left = 1800
TabIndex = 5
Top = 720
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objDX As New DirectX7
Dim objDS As DirectSound
Dim DSBuffer As DirectSoundBuffer
Dim bufferdss As DSBUFFERDESC
Dim waveformat As WAVEFORMATEX
Private Sub Form_Load()
Me.Show
Set objDS = objDX.DirectSoundCreate("")
objDS.SetCooperativeLevel Me.hWnd, DSSCL_NORMAL
bufferdss.lFlags = DSBCAPS_STATIC Or DSBCAPS_CTRLVOLUME Or DSBCAPS_CTRLPAN
With waveformat
.nFormatTag = 1
.nChannels = 1
.lSamplesPerSec = 22050
.lAvgBytesPerSec = 44100
.nBlockAlign = 2
End With
Set DSBuffer = objDS.CreateSoundBufferFromFile("sample1.wav", bufferdss, waveformat)
End Sub
Private Sub play_Click()
DSBuffer.Play DSBPLAY_DEFAULT
End Sub
Private Sub pause_Click()
DSBuffer.Stop
End Sub
Private Sub stop_Click()
DSBuffer.Stop
DSBuffer.SetCurrentPosition 0
End Sub
Private Sub volume_Change()
DSBuffer.SetVolume volume.Value
End Sub
Private Sub pan_Change()
DSBuffer.SetPan pan.Value
End Sub