1. Add Three buttons (button1, button2, button3) and a label (label1) to the form.
2. Set the Text of Button1 to Start, Button2 to Stop, and Button3 to Play.
3. Add this code:
VB.NET Code:
Public Class Form1
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(ByVal sender As System.Object, ByVal 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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
What is the point of having both a "Start" and "Play" button?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Does this work on Vista/Win7? Because I thought that the APIs needed to record audio output in real time were disabled in Vista and Win7 in order to prevent people recording music from internet radio and similar services...
EDIT: I also see that you have executable files in your archive, which is in violation of CodeBank policy. You should remove the bin and obj folders from the archive.
Last edited by obi1kenobi; Jul 17th, 2010 at 05:06 AM.
Reason: executable files in submission
Please rate helpful ppl's posts. It's the best 'thank you' you can give
First of all, you need elevatetion (admin permissions) to save to C:\ in Vista and Win7, so your app crashes when saving without that.
Second of all, the quality of the recording is poor to the point of it being unusable... I hope there is a way to change the output format and/or the bitrate...
Please rate helpful ppl's posts. It's the best 'thank you' you can give
Problem here is indeed saving at the wrong location.
Does this work on Vista/Win7? Because I thought that the APIs needed to record audio output in real time were disabled in Vista and Win7 in order to prevent people recording music from internet radio and similar services...
Yes it works on Vista/W7 even 64b.
Regarding the recording quality, what OS are you using? Mine's Vista SP2.
Its not depending of the OS but the default settings of of recording with MCI and your soundcard. Default the sample rate is 11025 and 8bits. You can change these settings with "mciSendString" http://msdn.microsoft.com/en-us/library/ms713255.aspx
This is the CodeBank because you can modify the code. Think of the path as a placeholder.
I'm using XP SP3.
I feel like I might have been misunderstood... I know that the path is a placeholder and that this is the CodeBank and everything... My point was that the path was hardcoded into the compiled application that was included in the post and if someone downloaded it and ran it on Vista/Win7, the application would crash, failing to demonstrate it's purpose. That might prompt this person to abandon this code, thinking that it doesn't work, when in fact it does. Anyway, it's not that important now Just wanted to clear it up a bit...
Please rate helpful ppl's posts. It's the best 'thank you' you can give
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(ByVal sender As System.Object, ByVal 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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Button1.Text = "Start"
Button2.Text = "Stop"
Button3.Text = "Play"
End Sub
End Class
Modified the original code so that it uses a save dialog.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672