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

New Post: Adaptive Mic Recording (Fill glap with silence to keep accurate time).

$
0
0
That's what i am trying to do know, not really sure how to do it.
                            if (Record)
                            {
                                if (FileCreated != 0)
                                {
                                    if (calltimer.IsRunning == false)
                                        CallTimeThread.Start();
                                    if (TimeSpan.FromMilliseconds(TestTimer / 192).Milliseconds < calltimer.ElapsedMilliseconds - 5000)
                                    {
                                        TestTimer = calltimer.ElapsedMilliseconds;
                                        int silence = (int)calltimer.ElapsedMilliseconds - TimeSpan.FromMilliseconds(TestTimer / 192).Milliseconds;
                                        TestTimer = calltimer.ElapsedMilliseconds * 192;
                                        int avgBytesPerMillisecond = 192;
                                        var silenceArraySize = avgBytesPerMillisecond * silence;
                                        byte[] silenceArray = new byte[silenceArraySize];
                                        waveWriterYour.Write(silenceArray, 0, silenceArray.Length);
                                    }
                                    this.BeginInvoke((Action)(() =>
                      {
                          RecTime.Text = TimeSpan.FromMilliseconds(TestTimer / 192).ToString();
                      }));
                                    waveWriterYour.Write(AudioData2, 0, AudioData2.Length);
                                    waveWriterYour.Flush();
                                }

                            }
This completely fails, but i guess it's somewhere on the line.

The TestTimer will be exactly the same time as the audio, meaning the timer itself is correct.
The other, CallTimer will begin at about the same time and just measure time itself, so when they are off, it means audio has been skipped (Though they aren't precise when they start, but at least it's pretty close, and can probably be done better.


Now i just want it to say, "If TestTimer is 100ms less than Calltimer, add 100ms Silence" , or something like that.

Which should make it fairly accurate, at least in theory.

Viewing all articles
Browse latest Browse all 5831

Trending Articles



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