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
Using a custom DataSink, as done by MicroPython, we can see that when pulling from the splitter channel, we end up with what it looks like missing data between the first and second buffer from the ADC.
This test was carried out with the current CODAL configuration where the ADC is set to 45454 Hz, and the example code then sets the splitter channel sample rate to 7812.
As the ADC DMA buffers are 512 bytes, and we have 14-bits per sample, we get 256 samples per buffer. Downsampling that buffer from 45454 to 7812, and we get 44 bytes left (256 / (45454 / 7812) ≈ 44).
This example code is configured use a custom DataSink to pull 128 bytes 10 times in a row (each time connecting and disconnecting from the pipeline) and the data can be printed to serial.
Then I've played a 382 Hz sine wave (just picked a random frequency that easily illustrates this issue) with my phone next to the micro:bit microphone and plotted the data. We can see that in all of the plots the wave glitches at the 44th byte.
Interestingly we don't see the same at the 88th byte, so I wonder if this only affects the boundary between the 1st and 2nd byte from the moment the splitter channel is connected?
To see if we could capture more than one glitch per "pipeline stream" (as the example code connects and disconnects the stream for each of the 128 byte plots), I've tried increasing each block of pulled data from 128 bytes to 256 bytes, and a few different sound frequencies (in case small offsets made it more obvious in the plot).
But, it looks like we really are only seeing the issue between the 1st and 2nd pull, at byte 44:
@microbit-carlos The first packet in each recording is an old packet, and the latest packet is dropped.
Based on a previous look, I think... When the StreamRecorder connects, the next generated ADC packet will prompt the pull request, but the buffer pulled from mic->output will be whatever it was holding before the packet generation, and the buffer the ADC just sent will be dropped.
By adding a serial number in the first byte of each ADC packet, and preserving it in StreamNormalizer, the packet numbers in each recording can be dumped. See below, two A presses.
It's clear that a packet is dropped in each recording, and the second batch starts with the old packet 39 that was not pulled through in the last batch. In fact, I think the first packet in each recording is an old one from just after the previous recording.
For the output below, I made the serial number a static. With the serial number as a member variable in NRF52ADCChannel, the numbers restart for the second batch (the first recording is 39 4 5), because the channel is released and recreated during the pause between A presses.
Using a custom
DataSink
, as done by MicroPython, we can see that when pulling from the splitter channel, we end up with what it looks like missing data between the first and second buffer from the ADC.This test was carried out with the current CODAL configuration where the ADC is set to 45454 Hz, and the example code then sets the splitter channel sample rate to 7812.
As the ADC DMA buffers are 512 bytes, and we have 14-bits per sample, we get 256 samples per buffer. Downsampling that buffer from 45454 to 7812, and we get 44 bytes left (
256 / (45454 / 7812) ≈ 44
).This example code is configured use a custom
DataSink
to pull 128 bytes 10 times in a row (each time connecting and disconnecting from the pipeline) and the data can be printed to serial.Then I've played a 382 Hz sine wave (just picked a random frequency that easily illustrates this issue) with my phone next to the micro:bit microphone and plotted the data. We can see that in all of the plots the wave glitches at the 44th byte.
Interestingly we don't see the same at the 88th byte, so I wonder if this only affects the boundary between the 1st and 2nd byte from the moment the splitter channel is connected?
MICROBIT.hex.zip
Source code
Press button A to record, and button B to print data to serial.
(I've omitted the first two buffers, as they contain bad data as caused by issue #442)
The text was updated successfully, but these errors were encountered: