Replies: 1 comment
-
cut down the code to a minimal reproducer you can post, or go the opposite route and add timestamp instrumentation to the reader example and see whether you can repro the issue. to see whether samples are dropped, don't go by the timing, but do a loopback recording of a clean wave (with an odd period length, to avoid aliasing) and see whether it comes back clean. also check without python in the loop, using just arecord and speaker-test. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
first of all, thanks for the great package! It makes using ALSA through Python so easy!
My goal is to get a timestamp with millisecond precision for the first sample in a period.
I need precision timestamps to investigate whether samples get dropped, how the sample rate might change over time, and if an audio recording needs to be adjusted / resampled to a given number of samples. This depends on the exact time it took to make this recording.
The greater goal is to precisely match events that occur in different recordings from multiple devices.
The devices are Raspberry Pi with a HifiBerry DAC+ ADC Pro.
My general setup is to open a thread for reading from the device and write the data (audio and timestamp) to a queue. Another thread reads the queue and writes the file.
I am using
htimestamp()
in conjunction withread()
. I was hoping, if I correct for the time it takes to capture a period, I might get close to a 0-millisecond difference between the first and last timestamp.But even when recording for just a couple of seconds, the difference between the calculated recording time (end - start) always deviates from the expected duration by 1 to 200 milliseconds. This kind of depends on the combination of the period size and the recording duration. But It's not always reproducible.
Because the time difference is not increasing with the recording duration, I suspect the error is somewhere in the code. My guess is that I am measuring code execution time, and not irregularities of the ADC.
Do you have any tricks or suggestions, how to get a precise timestamp for a specific frame?
Beta Was this translation helpful? Give feedback.
All reactions