How to open and save a Sound Recorder Output

Kenta

Member
Joined
Mar 17, 2012
Messages
21
Programming Experience
Beginner
Hello Everybody,

I'm having a difficulty building a Sound Recorder...
I have the following code so fa, i want the code to prompt the user where to save and what to open instead of defining them in the user, a.s.a.p help please:

VB.NET:
 Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False

        Button2.Enabled = True

        mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)

        mciSendString("record recsound", "", 0, 0)

        Label1.Text = "Recording..."

        Label1.Visible = True

    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Button1.Enabled = True
        Button2.Enabled = False
        Button3.Enabled = True

        mciSendString("save recsound c:\Users\EmoOoy\RECSOUND1.wav", "", 0, 0)
        mciSendString("close recsound", "", 0, 0)
        MsgBox("File Created: C:\recsound.wav")
        Label1.Text = "Stopped..."
        Label1.Visible = False
        My.Computer.Audio.Stop()
    End Sub

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        My.Computer.Audio.Play("c:\Users\EmoOoy\RE*CSOUND1.wav", AudioPlayMode.Background)
        Label1.Text = "Playing..."
        Label1.Visible = True

    End Sub
 
Then use an OpenFileDialog and SaveFileDialog to get the paths instead of hard-coding them. They can both be found in your Toolbox so you can add them directly to your form and configure them visually.
 
Then use an OpenFileDialog and SaveFileDialog to get the paths instead of hard-coding them. They can both be found in your Toolbox so you can add them directly to your form and configure them visually.

i added those two functions by coding, and they do open ... but ... the savefiledialog doesn't save (even though i specify the name of the file) and therefore can't open any...

//in need for method/function that's something like but for a sound file type outputfile.SaveFile(savefiledialog.filename)

which where i believe the problem is, because it doesn't do any coding...

i'll try doing what you said though, thank you for the reply
 
In your first post you imply that it works as expected if you hard-code the file path. All you have to do is substitute the FileName of the SaveFileDialog for that hard-coded file path. All the rest stays exactly as it is.
 

Latest posts

Back
Top