Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: recording while playing (synchronisation problem)

$
0
0

I'm using NAudio 1.4 and I want to record a fix duration of microphon input while some audio is playing in the background.

The audio plays some signals (metronom clicks) to which user must react (play a note on an instrument).  Playing and recording is started at the same time.

The problem is that the recorded audio is always "shifted" forward (between 50 and 120 milliseconds) == beginning too early

-> the instrument hits are not sync with the metronom clicks, although the were played excact the same time( the first instrument sound should start at 0 millisec but it starts between 50 and 120 millisec).

-> Therefore this timespan is missing at the end of the file, as I'm recording a fix length. If it was always the same timespan, I could handle it, but it seems to be random (let's assume that the mic input always starts at the same time (i'm currrently simulating the input by just placing the mic before my pc speaker, so basically i'm just recoding the metronom clicks itself...)

The following code (extract) gets executed in one new thread:

 


wavePlayer.Play(); // wavePlyer is IWavePlayer


// I'm using the (modified) class "AudioRecorder" that is provided in the NAudio Demo:

WaveFileWriter writer = new WaveFileWriter(waveFileName, recordingFormat);
recordingState = RecordingState.Recording;



  Any idea ? How to do accurate  full duplex recording -> keep sync with WaveIn stream and WaveOut stream?

 

henrik


Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>