JochenDB
JochenDB

Reputation: 587

Playback sound while recording

I want to record sound to a file and at the same time I want to be able to play audio from the same file in C#

For example, play the last 15 seconds but the microphone has to keep on registering and recording while replaying.

Is this possible and in that case, which is the best approach to do this?

Upvotes: 0

Views: 308

Answers (1)

nevets
nevets

Reputation: 4828

The answer is YES, and you should play around with low level audio API, namely WaveIn/Out functions from winmm.dll, through P/Invoke in C#.

In short words, you need to use WaveIn to capture input signal from a input device and store in some structure, then use WaveOut to play back the audio simultaneously, or some delay after.

Here is a project you can start with: a duplex audio player. You can download the project and play around with it and see how it achieves it, then do some modifications upon the project to achieve what you want :)

Upvotes: 1

Related Questions