Results 1 to 5 of 5

Thread: MCI Record/SaveFileDialog HELP!

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    6

    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.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    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)

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    6

    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.

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    6

    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
  •  



Click Here to Expand Forum to Full Width