im having problems when trying to record sound from microphone in my wpf application. here's my code:
public NAudio.Wave.WaveFileWriter wav_writer = null; // snemanje
public WaveIn strim;
private void snemanje_Click(object sender, RoutedEventArgs e)
{
strim = new WaveIn();
strim.WaveFormat = new WaveFormat(44100, 0);
SaveFileDialog svg = new SaveFileDialog();
svg.Filter = "*WAV File (*.wav)|*.wav;*";
svg.ShowDialog();
strim.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
wav_writer = new WaveFileWriter(svg.FileName, strim.WaveFormat);
strim.StartRecording();
}
public void waveInStream_DataAvailable(object sender, WaveInEventArgs e)
{
wav_writer.WriteData(e.Buffer, 0, e.BytesRecorded);
wav_writer.Flush();
}
everything works perfectly and the file is saved in the projects location, but i can not oppen it. it says that it is a wave file but everytime i want to play it, it says that i must find codecs for playing in that format (but there arent any).