Reputation: 13848
Using NAudio to capture a microphone records the exact same amount of buffer data every single time. But I'm trying to use WASAPI Loopback Capture and getting many packets that are larger than I would expect. Using a setting of 500ms for audioBufferMillisecondsLength
, I would expect 192,000 bytes per callback event, but instead I see sizes like:
192000
195840
195840
195840
218880
218880
218880
218880
218880
218880
215040
226560
215040
230400
215040
218880
222720
192000
192000
195840
192000
192000
195840
...
Over long recordings, I find the average bytes per event to be 195,951.2095, and this is making it impossible to synchronize this recording with other events at the time.
What is causing this variability, and how can I align such a recording with anything if the actual length of the recording is hard to predict like this?
Upvotes: 1
Views: 429
Reputation: 69734
Loopback capture exposes data copied from playback pipeline, which in turn has its own granularity of buffers. Then, loopback capture does not expose any silence: hence once in a while you will see partial buffers too.
Variable buffer sizes are okay and you have perfect way to synchronize the data. If there is a gap between buffers you have a discontinuity flag indicating this. Otherwise data is continuous no matter what buffer size is.
Upvotes: 0