Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording with a low rate doesn't work #201

Open
microbit-carlos opened this issue Apr 24, 2024 · 3 comments
Open

Recording with a low rate doesn't work #201

microbit-carlos opened this issue Apr 24, 2024 · 3 comments
Assignees
Labels
bug Something isn't working CODAL
Milestone

Comments

@microbit-carlos
Copy link
Contributor

microbit-carlos commented Apr 24, 2024

Tested with the latest version of the recording & playback branch: c91ae4e

When the recording rate is set below 143 the recording function returns immediately without filling the AudioFrame.

>>> af = audio.AudioFrame()
>>> bytes(af)    # Default value is 0x80
b'\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80'
>>> # Timing how long it takes to record at 142 samples per second
>>> t = running_time(); microphone.record_into(af, rate=142); running_time() - t
1
>>> bytes(af)    # AudioFrame data untouched
b'\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80'
>>> t = running_time(); microphone.record_into(af, rate=143); running_time() - t
181
>>> bytes(af)
b'\x80\x81\x80\x7f\x80\x80\x80\x80\x80\x80\x81}~\x82}\x7f{\x81\x7f\x80\x81|\x81\x80\x7f|\x80\x84n\x8ey\x8a'
>>> 
>>> t = running_time(); af = microphone.record(100, 142); running_time() - t
1
>>> bytes(af)
b'\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80'
>>> t = running_time(); af = microphone.record(100, 143); running_time() - t
178
>>> bytes(af)
b'\x80\x81\x86}\x7f\x80|\x7f~\x81|||~\x82\x7f\x7f\x80\x7fz\x80\x82\x82|\x80\x80{\x80}}\x81\x82'
>>> 

I guess this could be an issue in the CODAL layer, if that's the case let me know and I'll raise it in the codal-microbit-v2 repository.

@dpgeorge
Copy link
Collaborator

I guess this could be an issue in the CODAL layer

I can't see any reason why a rate of 142 is different to a rate of 143 on the MicroPython side, so, yes, this looks like an issue in CODAL.

@microbit-carlos
Copy link
Contributor Author

I'll try to create an example to replicate in CODAL and raise this issue there.

@microbit-carlos
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CODAL
Projects
None yet
Development

No branches or pull requests

2 participants