We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
Unless I am misunderstanding this, which is possible, I would have expected the DataAvailable event to be raised less frequently.
I am trying to process audio in near realtime although stability is important so I am happy with 100 to 200 milliseconds.
Recording in 8kHz, 16 bit, mono.
Example code
private WasapiCapture soundIn; private SoundInSource soundInSource; private IWaveSource finalSource; private MMDevice AudioDeviceIn; Debug.WriteLine(DateTime.Now.ToString("HHmmss.fff") + "\t" + "recorder format = " + AudioDeviceIn.DeviceFormat.ToString()); soundIn = new WasapiCapture(true, AudioClientShareMode.Shared, 120, new WaveFormat(8000, 16, 1)); soundIn.Device = AudioDeviceIn; soundIn.Initialize(); soundInSource = new SoundInSource(soundIn); soundInSource.FillWithZeros = false; var simpleStream = new SimpleNotificationSource(soundInSource.ToSampleSource()); finalSource = simpleStream.ToWaveSource(16); soundInSource.DataAvailable += GotAudioData; soundIn.Start(); private void GotAudioData(object sender, DataAvailableEventArgs e) { Debug.WriteLine(DateTime.Now.ToString("HHmmss.fff") + "\t" + "got bytes = " + e.ByteCount); byte[] buffer = new byte[finalSource.WaveFormat.BytesPerSecond]; int read; int bytesPerSample; int howManySamples; while ((read = finalSource.Read(buffer, 0, buffer.Length)) > 0) { Debug.WriteLine(DateTime.Now.ToString("HHmmss.fff") + "\t" + "read = " + read + " from finalSource"); bytesPerSample = finalSource.WaveFormat.BytesPerSample; howManySamples = read / bytesPerSample; } }
Debugging shows the DataAvailable event seems to be triggered every 20ms, sometimes as low as 10ms. (2 bytes per sample)
092727.219 recorder format = ChannelsAvailable: 1|SampleRate: 8000|Bps: 16000|BlockAlign: 2|BitsPerSample: 16|Encoding: Extensible|SubFormat: 00000001-0000-0010-8000-00aa00389b71|ChannelMask: SpeakerFrontCenter 092727.298 got bytes = 320 092727.302 read = 320 from finalSource 092727.315 got bytes = 320 092727.316 read = 320 from finalSource 092727.336 got bytes = 320 092727.337 read = 320 from finalSource 092727.355 got bytes = 320 092727.356 read = 320 from finalSource 092727.375 got bytes = 320 092727.376 read = 320 from finalSource 092727.395 got bytes = 320 092727.396 read = 320 from finalSource 092727.416 got bytes = 320 092727.417 read = 320 from finalSource 092727.436 got bytes = 320 092727.436 read = 320 from finalSource 092727.456 got bytes = 320 092727.457 read = 320 from finalSource 092727.476 got bytes = 320 092727.476 read = 320 from finalSource 092727.496 got bytes = 320 092727.496 read = 320 from finalSource 092727.515 got bytes = 320 092727.516 read = 320 from finalSource 092727.535 got bytes = 320 092727.536 read = 320 from finalSource 092727.555 got bytes = 320 092727.557 read = 320 from finalSource 092727.575 got bytes = 320 092727.577 read = 320 from finalSource 092727.595 got bytes = 320 092727.597 read = 320 from finalSource 092727.605 got bytes = 160 092727.606 read = 160 from finalSource 092727.625 got bytes = 320 092727.626 read = 320 from finalSource 092727.636 got bytes = 160 092727.637 read = 160 from finalSource
The text was updated successfully, but these errors were encountered:
Stable wasapi capture latency. see #321.
8f3b4da
You're right. It was an old relict. I've fixed it. Should be stable now. Decreased the default latency to 25ms. Should be quite stable now.
Sorry, something went wrong.
No branches or pull requests
Hi,
Unless I am misunderstanding this, which is possible, I would have expected the DataAvailable event to be raised less frequently.
I am trying to process audio in near realtime although stability is important so I am happy with 100 to 200 milliseconds.
Recording in 8kHz, 16 bit, mono.
Example code
Debugging shows the DataAvailable event seems to be triggered every 20ms, sometimes as low as 10ms. (2 bytes per sample)
The text was updated successfully, but these errors were encountered: