"Recording a sound" Help

pb_ce85's Avatar, Join Date: Jul 2008
Newbie Member
Hello
Does anyone knows how can record a sound from an available microphone?
Thanks
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
To help others with similar problem, I'm posting a solution though its late by 9 months

I would have achieved sound recording in C# by using mciSendStringA in winmm.dll.

First import the dll :
Code: c#
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Auto]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
Now, create a new device (named MyRecorder) :
Code: c#
mciSendString("open new type waveaudio alias MyRecorder", "" , 0, 0);
To start sound recording :
Code: c#
mciSendString("record MyRecorder", "" , 0, 0);
To save the recorded sound (to C:\MySound.wav):
Code: c#
mciSendString("save MyRecorder C:\\MySound.wav", "" , 0, 0);
To stop recording sound :
Code: c#
mciSendString("close MyRecorder", "" , 0, 0);
That's it !

For complete list of MCI Strings, go here : http://msdn.microsoft.com/en-us/libr...loband%29.aspx

I hope this post would be useful to many .