tags:

views:

106

answers:

2

When I try recording audio following this here, and using the related source code from here in the (voicerecorder.audio project), I face the problem that the recording stops within moments of starting and so does the playback. the recorded file is 46 bytes, and playback is there for less than a second, basically, the thread jumps to the next statement immediately. If I try to sleep the thread, it doesn't help. What can I do to keep it in the recording mode or playback mode until user interrupt ?

+1  A: 

A short but complete code example may help you get good answers.

In lieu of that, one thing you should make sure that your main thread (assuming this is a console app) does not terminate immediately after starting the audio recording. When the main app thread terminates in .NET, the entire process is terminated - background or worker threads do not keep the process alive.

LBushkin
+1  A: 

I've answered on the NAudio forums: http://naudio.codeplex.com/Thread/View.aspx?ThreadId=207713

But LBushkin is on the right lines. You need to keep the thread alive while the recording is taking place, and if you are using windowed callbacks, there needs to be a window. Use function callbacks for Console applications.

Mark Heath