English 中文(简体)
Audio recording and playback using NAudio
原标题:

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 ?

最佳回答

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.

问题回答

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签