【VB开源代码栏目提醒】:网学会员为广大网友收集整理了,frmAudioRecorder.frm,希望对大家有所帮助!
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form AudioRecorder
BorderStyle = 1 'Fixed Single
Caption = "录音
程序"
ClientHeight = 3765
ClientLeft = 45
ClientTop = 330
ClientWidth = 6315
Icon = "frmAudioRecorder.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3765
ScaleWidth = 6315
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdSettings
Caption = "设置"
Height = 495
Left = 5040
TabIndex = 9
ToolTipText = "Change rate, stereo/mono, 8/16 bits and program an automatic recording"
Top = 120
Width = 975
End
Begin MSComctlLib.Slider Slider1
Height = 375
Left = 240
TabIndex = 7
ToolTipText = "You can choose a beginning for playing the recording"
Top = 960
Width = 4575
_ExtentX = 8070
_ExtentY = 661
_Version = 393216
LargeChange = 500
SmallChange = 100
TickStyle = 3
End
Begin VB.CommandButton cmdReset
Caption = "重置"
Height = 495
Left = 120
TabIndex = 4
ToolTipText = "To start a new recording and adjusting all settings"
Top = 120
Width = 975
End
Begin VB.CommandButton cmdSave
Caption = "保存"
Enabled = 0 'False
Height = 495
Left = 4020
TabIndex = 3
ToolTipText = "Save the recording as as WAV file"
Top = 120
Width = 975
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 5280
Top = 1680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
FileName = " "
Orientation = 2
End
Begin VB.CommandButton cmdPlay
Caption = "播放"
Enabled = 0 'False
Height = 495
Left = 3045
TabIndex = 2
ToolTipText = "Play the recording"
Top = 120
Width = 975
End
Begin VB.CommandButton cmdStop
Caption = "停止"
Enabled = 0 'False
Height = 495
Left = 2070
TabIndex = 1
ToolTipText = "Stop recording or playing"
Top = 120
Width = 975
End
Begin VB.CommandButton cmdRecord
Caption = "录音"
Height = 495
Left = 1095
TabIndex = 0
ToolTipText = "Start recording immediate"
Top = 120
Width = 975
End
Begin
VB.Frame Frame5
Caption = "开始播放位置"
Height = 855
Left = 120
TabIndex = 8
Top = 720
Width = 4815
End
Begin VB.Timer Timer2
Interval = 200
Left = 5160
Top = 2400
End
Begin VB.Frame Frame4
Caption = "参数"
Height = 1815
Left = 120
TabIndex = 5
Top = 1680
Width = 4815
Begin VB.Label StatisticsLabel
BackColor = &H00000000&
Caption = " "
ForeColor = &H0000FF00&
Height = 1455
Left = 120
TabIndex = 6
ToolTipText = "Information about the recording"
Top = 240
Width = 4575
End
End
End
Attribute VB_Name = "AudioRecorder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const AppName = "AudioRecorder"
Private Sub cmdSave_Click()
Dim sName As String
If WaveMidiFileName = "" Then
sName = "Radio_from_" & CStr(WaveRecordingStartTime) & "_to_" & CStr(WaveRecordingStopTime)
sName = Replace(sName, ":", "-")
sName = Replace(sName, " ", "_")
sName = Replace(sName, "/", "-")
Else
sName = WaveMidiFileName
sName = Replace(sName, "MID", "wav")
End If
CommonDialog1.FileName = sName
CommonDialog1.CancelError = True
On Error GoTo ErrHandler1
CommonDialog1.Filter = "WAV file (*.wav*)|*.wav"
CommonDialog1.Flags = &H2 Or &H400
CommonDialog1.ShowSave
sName = CommonDialog1.FileName
WaveSaveAs (sName)
Exit Sub
ErrHandler1:
End Sub
Private Sub cmdRecord_Click()
Dim settings As String
Dim Alignment As Integer
Alignment = Channels * Resolution / 8
settings = "set capture alignment " & CStr(Alignment) & " bitspersample " & CStr(Resolution) & " samplespersec " & CStr(Rate) & " channels " & CStr(Channels) & " bytespersec " & CStr(Alignment * Rate)
WaveReset
WaveSet
WaveRecord
WaveRecordingStartTime = Now
cmdStop.Enabled = True 'Enable the STOP BUTTON
cmdPlay.Enabled = False 'Disable the "PLAY" button
cmdSave.Enabled = False 'Disable the "SAVE AS" button
cmdRecord.Enabled = False 'Disable the "RECORD" button
End Sub
Private Sub cmdSettings_Click()
Dim strWhat As String
' show the user entry form modally
strWhat = MsgBox("If you continue your data will be lost!", vbOKCancel)
If strWhat = vbCancel Then
Exit Sub
End If
Slider1.Max = 10
Slider1.Value = 0
Slider1.Refresh
cmdRecord.Enabled = True
cmdStop.Enabled = False
cmdPlay.Enabled = False
cmdSave.Enabled = False
WaveReset
Rate = CLng(GetSetting("AudioRecorder", "StartUp", "Rate", "110025"))
Channels = CInt(GetSetting("AudioRecorder", "StartUp", "Channels", "1"))
Resolution = CInt(GetSetting("AudioRecorder", "StartUp", "Resolution", "16"))
WaveFileName = GetSetting("AudioRecorder", "StartUp", "WaveFileName", "C:\Radio.wav")
WaveAutomaticSave = GetSetting("Audi