Link to home
Start Free TrialLog in
Avatar of DoctorNash
DoctorNash

asked on

Recording a WAV file

Experts,
I've tried the following code on 2 PCs and I'm getting the same negative results. The code is supposed to record the output from the soundcard to a WAV file (regardless of what audio the soundcard is playing - could be a CD, another WAV, mic etc). I think the code itself is fine - it is definitely recording a WAV file, and the resulting WAV file is playable by any media player, but in every case the WAV file contains no audio content - nothing, zippo, nadda - dead silence. Is there something I need to configure in Windows? Both PCs are running Windows 2000 -one's a laptop and the other a desktop with a Soundblaster Live!
Thanks muchly,
DocNash

Option Explicit

Private 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

Const Path$ = "c:\Test.wav"

Dim RS$, CB&

Private Sub Command1_Click()
  If Dir$(Path, vbNormal) <> "" Then Kill Path
  RS = Space$(128)
     
  Call mciSendString("open new type waveaudio alias capture", _
                     RS, 128, CB)
  Call mciSendString("record capture", RS, 128, CB)
 
  Command1.Enabled = False
  Command2.Enabled = True
 End Sub
 
Private Sub Command2_Click()
  RS = Space$(128)
  Call mciSendString("stop capture", RS, 128, CB)
  Call mciSendString("save capture " & Path, RS, 128, CB)
  Call mciSendString("close capture", RS, 128, CB)
 
  Command1.Enabled = True
  Command2.Enabled = False
 End Sub
ASKER CERTIFIED SOLUTION
Avatar of bmatumbura
bmatumbura

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial