Closed microbit-giles closed 3 months ago
@JohnVidler I think this is a CODAL issue that specifically has to do with splitterChannel->requestSampleRate(float samplerate)
.
It took me a bit to realize, but the problem emerges with the bottom sample rate call being a larger value than the top sample rate call. Once the sample rate gets set to 18000 for the upstream, the value of the input sample rate will never change due to this check here: https://github.com/lancaster-university/codal-core/blob/763a2d1a916d4db3fe3f3f2b1eaa9947cc8d0a7e/source/streams/StreamSplitter.cpp#L126. If we try to press A again, the upstream input sample rate is larger than what we are trying to change the sample rate to (11000), so we never get to request that sample rate to the upstream and thus the input sample rate for stays at 18000 while the playback rate changes back down to 11000. Thus, when we go to change both the sample rate and the playback to 18000, nothing happens to the input sample rate, but the output sample rate goes back to 18000, thus making the playback on the second go-round and beyond sound not sped up.
This can be seen by trying the following program Changing the sample rate in the same two places works as expected. The playback is slow every time:
This problem came to my attention when I noticed that just setting the playback sample rate in the second set sample rate
call did not cause the same bug as noticed above.
Describe the bug If you set the sample rate, record a sound, change the sample rate and play it back, the change just before playback only happens once. On subsequent runs of the code, the playback sample rate defaults back to its previous value.
To Reproduce Steps to reproduce the behavior:
Expected behavior The play back sound should always be speeded up.
Screenshots
micro:bit version (please complete the following information): tested on V2.00
Additional context If you explicitly set recording and playback sample rates, the project works as expected, but I expect the default behaviour to be consistent, and in this case always play back speeded up audio.