📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "播放.WAV文件显示波形"
ClientHeight = 1020
ClientLeft = 45
ClientTop = 330
ClientWidth = 4725
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1020
ScaleWidth = 4725
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 3360
Top = 600
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3960
Top = 600
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 375
Left = 840
TabIndex = 3
Top = 120
Width = 3615
End
Begin VB.CommandButton Command1
Caption = "文件"
Height = 375
Left = 120
TabIndex = 2
Top = 120
Width = 615
End
Begin VB.CommandButton Command3
Caption = "停止"
Height = 375
Left = 1320
TabIndex = 1
Top = 600
Width = 975
End
Begin VB.CommandButton Command2
Caption = "播放"
Height = 375
Left = 120
TabIndex = 0
Top = 600
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim filename As String ' wave file to play
Dim errStr As String * 200 ' buffer for retrieving error messages
Dim waveForm As Form2 ' form to draw wavegraph on
Const MAX_SCROLL_VALUE = 1000 ' range for scroll controls
Private Sub Form_Load()
' Initialize form, create wavegraph form
Module1.fFileLoaded = False
CommonDialog1.filename = "*.wav"
CommonDialog1.DefaultExt = "wav"
Set waveForm = New Form2
waveForm.Move Me.Left, Me.Top + Me.Height, Me.Width, Me.Height * 1.5
End Sub
Private Sub Command1_Click()
'Open a wavefile and initialize the form
CommonDialog1.ShowOpen
filename = CommonDialog1.filename
Text1.Text = filename
LoadFile filename
Module1.drawFrom = 0
Module1.drawTo = Module1.numSamples
waveForm.DrawWaves
End Sub
Private Sub Command2_Click()
' Start playing the wavefile
waveForm.Move Me.Left, Me.Top + Me.Height, Me.Width, Me.Height * 1.5
waveForm.Show 0, Me
If (Module1.fPlaying = False) Then
' -1 specifies the wave mapper
Play -1
End If
End Sub
Private Sub Command3_Click()
' Stop playing the wavefile
StopPlay
Unload waveForm
End Sub
Private Sub SetPlayRange()
' Set the range to be played and redraw the wave graph
Module1.drawFrom = CLng(Module1.numSamples * (HScroll1.Value / MAX_SCROLL_VALUE))
Module1.drawTo = CLng(Module1.numSamples * (HScroll2.Value / MAX_SCROLL_VALUE))
waveForm.DrawWaves
End Sub
Private Sub Timer1_Timer()
If Module1.fPlaying = False Then
Module1.CloseWaveOut
Timer1.Enabled = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -