|
-
Apr 4th, 2009, 09:28 PM
#1
Thread Starter
New Member
MCI Record/SaveFileDialog HELP!
i have a program that records audio using MCI, it works great, except i erase the previous made file every time i record a new one, because i didnt use a "SaveFileDialog".
Code:
Dim i As Long
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
Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Record.Click
' record from microphone
i = mciSendString("open new type waveaudio alias RecWavFile", 0&, 0, 0)
i = mciSendString("record RecWavFile", 0&, 0, 0) 'record
End Sub
Private Sub Save_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
' stop and save
i = mciSendString("Stop RecWavFile", 0&, 0, 0) 'stop record
i = mciSendString("save RecWavFile test.wav", 0&, 0, 0) 'save
i = mciSendString("close RecWavFile", 0&, 0, 0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.Audio.Play("test.wav")
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
so i figure i could just replace all the "test.wav"'s with SaveFileDialog.filename
Code:
Dim i As Long
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
Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Record.Click
' record from microphone
i = mciSendString("open new type waveaudio alias RecWavFile", 0&, 0, 0)
i = mciSendString("record RecWavFile", 0&, 0, 0) 'record
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' stop and save
SaveFileDialog1.InitialDirectory = "c:\"
SaveFileDialog1.DefaultExt = ".wav"
SaveFileDialog1.Filter = "Wave Files|*.wav"
SaveFileDialog1.FilterIndex = 1
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Filetosave As String = "save recsound " & SaveFileDialog1.FileName
mciSendString(Filetosave, "", 0, 0)
Else
MsgBox("You no Save!!!")
End If
mciSendString("close recsound", "", 0, 0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.Audio.Play("test.wav")
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
any help to what i am doing wrong would be great!
67% of statistics are made up on the spot. 
-
Apr 5th, 2009, 10:36 AM
#2
Re: MCI Record/SaveFileDialog HELP!
I havent used that API, but shouldnt you have;
Dim Filetosave As String = "save RecWavFile " & SaveFileDialog1.FileName
and
mciSendString("close RecWavFile", "", 0, 0)
-
Apr 5th, 2009, 02:42 PM
#3
Thread Starter
New Member
Re: MCI Record/SaveFileDialog HELP!
oh yes, sorry, i typed in my code wrong, in the program i DOES have the correct Variable, but i didnt copy and paste my code.
Code:
Dim i As Long
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
Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Record.Click
' record from microphone
i = mciSendString("open new type waveaudio alias RecWavFile", 0&, 0, 0)
i = mciSendString("record RecWavFile", 0&, 0, 0) 'record
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' stop and save
SaveFileDialog1.InitialDirectory = "c:\"
SaveFileDialog1.DefaultExt = ".wav"
SaveFileDialog1.Filter = "Wave Files|*.wav"
SaveFileDialog1.FilterIndex = 1
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim Filetosave As String = "save RecWavFile " & SaveFileDialog1.FileName
mciSendString(Filetosave, "", 0, 0)
Else
MsgBox("You no Save!!!")
End If
mciSendString("close RecWavSound", "", 0, 0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.Audio.Play("test.wav")
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
67% of statistics are made up on the spot. 
-
Apr 5th, 2009, 05:21 PM
#4
Re: MCI Record/SaveFileDialog HELP!
Try putting the filename in quotes;
Dim Filetosave As String = "save RecWavFile " & """" & SaveFileDialog1.FileName & """"
Also, where in you code do you "stop"?
Last edited by Bulldog; Apr 5th, 2009 at 05:37 PM.
-
Apr 5th, 2009, 10:26 PM
#5
Thread Starter
New Member
Re: MCI Record/SaveFileDialog HELP!
oh, wow, i feel VERY stupid. i have going through alot of trouble over me forgeting to STOP THE RECORDING! all i did was added
Code:
i = mciSendString("Stop RecWavFile", 0&, 0, 0) 'stop record
rite before the save file dialog, and it did the trick. thank you!
67% of statistics are made up on the spot. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|