there is a problem with recording i cant play it.players says this item's file format may be unsupported.
private void button1_Click(object sender, EventArgs e)
{
recorder = new WaveIn();
recorder.WaveFormat = new WaveFormat(44100, 1);
recorder.StartRecording();
}
private void button2_Click(object sender, EventArgs e)
{
var filewriter = new WaveFileWriter("C:\\Users\\oguzhan\\ödev\\deneme.wav", recorder.WaveFormat);
recorder.StopRecording();
WaveStream mainOutputStream = new WaveFileReader("C:\\Users\\oguzhan\\ödev\\deneme.wav");
WaveChannel32 volumeStream = new WaveChannel32(mainOutputStream);
player = new WaveOut();
player.Init(volumeStream);
player.Play();
}
As you have it at the moment you create the WaveFileWriter
object, stop recording, then write nothing to the wav file. What you end up with is an empty file that will not be even slightly useful.
Create the WaveFileWriter
first, before you start the recording. In the DataAvailable
event handler for your recorder
object write the received sample data to the WaveFileWriter
. Then when you are done with the recording, dispose of the WaveFileWriter
to finalize it.
Once you have done that you should have a valid wav file.