How to Create a Sound Recorder

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
7 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

How to Create a Sound Recorder
GoodGuy17
Hello,

In this tutorial, we are going to learn how to create a sound recorder. Now, note this: this WILL NOT be a professional sound recording application, just a simple Record/Stop/Play recorder. Credits for me learning this: YouTube (forgot which video :? maybe someone else can find it)

Let's Go!

OK, start up Visual Basic. Title your program anything you want, but I will name mine "Sound Recorder".

Controls:

Object = Label, Name = Label1, Text = Ready..., Font = Default w/ Bold
Object = Button, Name = Button1, Text = Start
Object = Button, Name = Button2, Text = Stop
Object = Button, Name = Button3, Text = Play
Object = BackgroundWorker, Name = BackgroundWorker1

I organized my controls like in the picture below:
Image


Code:

Go into the code, and add this right under Public Class Form1:
Code: Select all
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstyCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
This code is calling the DLL called winmm so we can use it.

Go into the code for your Start button click event, and add this code:
Code: Select all
        'Enable Stop button
        Button2.Enabled = True
        'Disable Play button
        Button3.Enabled = False
        'Disable Start button
        Button1.Enabled = False
        'Start recording
        mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
        mciSendString("record recsound", "", 0, 0)
        'Show status
        Label1.Text = "Recording..."
Go into the code for the Stop button click event, and add this code:
Code: Select all
        'Enable Start button
        Button1.Enabled = True
        'Enable Play button
        Button3.Enabled = True
        'Disable Stop button
        Button2.Enabled = False
        'Save recording
        mciSendString("save recsound C:\record.wav", "", 0, 0)
        mciSendString("close recsound", "", 0, 0)
        'Show status
        Label1.Text = "Finished"
Go into the code for the Play button click event, and add this code:
Code: Select all
        'Show status
        Label1.Text = "Playing..."
        'Disable Play button
        Button3.Enabled = False
        'Disable Stop button
        Button2.Enabled = False
        'Disable Start button
        Button1.Enabled = False
        'Play recording
        Me.BackgroundWorker1.RunWorkerAsync()
Go into the code for the BackgroundWorker dowork event, and add this code:
Code: Select all
        'Play audio
        My.Computer.Audio.Play("C:\record.wav", AudioPlayMode.WaitToComplete)
        'Enable Start button
        Button1.Enabled = True
        'Disable Stop button
        Button2.Enabled = False
        'Enable Play button
        Button3.Enabled = True
        'Threading.Thread.Sleep
        Threading.Thread.Sleep(250)
Go into the code for the BackgroundWorker runworkercompleted event, and add this code:
Code: Select all
        'Show status
        Me.Label1.Text = "Done"
About:

I did not explain the code, because it is heavily commented. This should be good enough to learn this, as I commented it well, I think. Please +rep if you liked this!

~GoodGuy17 :D
User avatar
volttide
VIP - Donator
VIP - Donator
Posts: 106
Joined: Mon Jan 17, 2011 8:24 am

Re: How to Create a Sound Recorder
volttide
thanks, this project is work
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: How to Create a Sound Recorder
MrAksel
Finally someone posted here Reboh, but i have used this code a while but can i post the app here?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: How to Create a Sound Recorder
GoodGuy17
Yea, sure. No credits needed (like, text, not Code Credits).
User avatar
Skillful
Skillful Coders
Skillful Coders
Posts: 969
Joined: Tue Nov 16, 2010 10:07 am

Re: How to Create a Sound Recorder
Skillful
Nice tutorial GoodGuy17! BTW did you actually use it in any of your apps?
+rep too :)
Instead of LOL use this -
LSIBMHBIWFETALOL

Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: How to Create a Sound Recorder
MrAksel
GoodGuy17 wrote:
Yea, sure. No credits needed (like, text, not Code Credits).
Ok thanks
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

CoderBoy1201 wrote:
Nice tutorial GoodGuy17! BTW did you actually use it in any of your apps?
+rep too :)
No, not really, but I was wanting to make a voice editing program once, and I could never figure out how to auto-tune.
7 posts Page 1 of 1
Return to “Tutorials”