by Patrick K. Bigley (14 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (5 Votes)
Finally, the RECORD source code for WAV files is here. Very easy, yet getting this (and all MCI commands) from Microsoft is like pulling teeth. We need simple code, so I brought this to you. Enjoy. I believe that I will start a website very soon, that will contain the entire listing and usage of the MCI Commands for the ordinary programmer like ourselves.
Assumes
Create a form (Form1). Add 3 command buttons to the form (Command1 Command2 Command3).
Code Returns
Creates a WAV file
API Declarations'Included in the code below. Nothing here...(don't copy)
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
hwndCallback As Long) As Long
Private Sub Command1_Click()
i = mciSendString("open new type waveaudio alias capture", 0&, 0, 0)
i = mciSendString("set capture bitspersample 8", 0&, 0, 0)
i = mciSendString("set capture samplespersec 11025", 0&, 0, 0)
i = mciSendString("set capture channels 1", 0&, 0, 0)
i = mciSendString("record capture", 0&, 0, 0)
'bitspersample can be:
' 8
' 16
'
'samplespersec can be:
' 11025
' 22050
' 44100
'
'channels can be:
' 1 = mono
' 2 = stereo
End Sub
Private Sub Command2_Click()
i = mciSendString("stop capture", 0&, 0, 0)
i = mciSendString("save capture c:\NewWave.wav", 0&, 0, 0)
' i = mciSendString("close capture", 0&, 0, 0)
End Sub
Private Sub Command3_Click()
i = mciSendString("play capture from 0", 0&, 0, 0)
End Sub
Private Sub Form_Load()
Me.Caption = "WAVE RECORDER"
Command1.Caption = "Record"
Command2.Caption = "Stop"
Command3.Caption = "Play"
End Sub
Private Sub Form_Unload(Cancel As Integer)
i = mciSendString("close capture", 0&, 0, 0)
End Sub