You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to do an audio recording with a sampling rate of 142 or lower results in no data being pulled from the DataSource.
This is replicable with the default StreamRecording, however before being able to set a sampling rate of 142, we are first hit with issue #427 (triggered with a sample rate lower than 320) which hides this problem.
Using a custom DataSink, like MicroPython, we can confirm that no data is pulled from upstream if the sampling rate is set to 142 or lower:
From an ADC sampling period set to 22 microsec 1000000/22 = 45454, which is configured when the audio pipeline sets the sampling rate to to 44100 and that calculates the period as an int with 1000000/44100=22.67
The DataSource pull contains 256 samples
With the DataSink sampling rate set to 142, you end up with
byteDeficit = 45454-142 = 45312
packetsPerSec = 45454 / 256 = 177
dropPerPacket = 45312 / 177 = 256 <-- Basically drop the entire packet
samplesPerOut = 256 - 256 = 0 <-- Or in other words, keep zero samples
Also interesting to note that samplesPerOut is set to zero, but the division in StreamSplitter.cpp#L84 doesn't cause an exception 🤷♂️
The text was updated successfully, but these errors were encountered:
A simple fix would be to change the zero samplesPerOut to one, unless totalSamples is zero, which would make 177 the minimum rate.
Perhaps slower rates could calculate the skip between readings and remember an index from block to block, something like... if skip is 300 take samples from successive blocks 0, 44 (=300-256), 88, 132, 176, 220, miss one, 8, 52, etc.
From this MicroPython bug:
Trying to do an audio recording with a sampling rate of 142 or lower results in no data being pulled from the DataSource.
This is replicable with the default
StreamRecording
, however before being able to set a sampling rate of 142, we are first hit with issue #427 (triggered with a sample rate lower than 320) which hides this problem.Using a custom DataSink, like MicroPython, we can confirm that no data is pulled from upstream if the sampling rate is set to 142 or lower:
Source code with custom DataSink
Essentially it comes down to
SplitterChannel::resample()
:45454
1000000/22 = 45454
, which is configured when the audio pipeline sets the sampling rate to to 44100 and that calculates the period as an int with1000000/44100=22.67
256
samples142
, you end up withAlso interesting to note that
samplesPerOut
is set to zero, but the division in StreamSplitter.cpp#L84 doesn't cause an exception 🤷♂️The text was updated successfully, but these errors were encountered: