Record and play audio using NAudio

When I try to record audio, following this here , and using the appropriate source code from here in the project (voicerecorder .audio ), I encounter the problem that the recording stops at startup times, as well as playback. the recorded file is 46 bytes, and playback takes less than a second, basically, the stream goes directly to the next statement. If I try to sleep, it will not help. What can I do to save it in recording mode or in playback mode until the user interrupts?

+3
source share
2 answers

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

But L. Bushkin is on the right track. You need to save the stream during the recording process, and if you use window callbacks, there should be a window. Use function callbacks for console applications.

+1
source

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

Instead, you need to make sure that your main stream (provided that it is a console application) does not stop immediately after starting the audio recording . When the main application thread terminates in .NET, the entire process terminates — background or worker threads do not support this process.

+1
source

Source: https://habr.com/ru/post/1739042/


All Articles