-
Notifications
You must be signed in to change notification settings - Fork 659
call scaled microphone API instead of using our own scaling #6194
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
base: master
Are you sure you want to change the base?
Conversation
Thanks @riknoll! I just realised that to keep the current behaviour exactly the same we need to set these values in the codal.json file:
This is because the CODAL default values are currently different, so setting these macros configures the sound level with the same range as before. The underlying issue with #4381 was that the Sound Level detector never returns a value above ~100 dB (blowing directly on the microphone should saturate it and the max value is around that), so having the 8-bit max point at 120 dB means the sound level block output was never above ~191. If we set 8-bit max point to 100 dB that will also change the scaling, so programmes that before outputted an 8-bit value of |
@microbit-carlos if we are just going to set the scaling back to the original value, is there a point to merging this at all? |
One of the reasons to have this completely managed by CODAL is because we are doing an audio pipeline refactor and that affects the decibel calculations. As we haven't really exposed the dB sound level in the MakeCode nor the MicroPython API that won't affect most users, but we do need to tweak the 8-bit min and max values to match the current implementation. Ideally we'd set MakeCode to use both these default values, and have it completely managed by CODAL, but it wasn't until now that I realised that fixing this bug might break some of the existing user projects. Btw, I've just release codal v0.2.70 to ensure the micro:bit target uses the default min value as 52 and max value as 100 (I thought this was done in release 0.2.44, but looks like we didn't get around to it). So, it's not ideal to have the max value configured differently in MakeCode, but based initial testing of the audio refactor branch I think we might only need to tweak the min value, and so that would mean that future CODAL release would not need to be accompanied by a pxt code change. |
The v0.2.70 mostly includes minor bug fixes and CI updates, although it does also include a couple of patches to ensure floating point operations don't unnecessarily perform double operations and that saves about half a kilobyte of flash, and should also provide some minor performance improvements. https://github.com/lancaster-university/codal-microbit-v2/blob/master/Changelog.md#v0270 |
@riknoll good news, after careful consideration the team is happy to include the bugfix as well, so we can let CODAL manage both the min and max values. It still needs the latest v0.2.70 tag, but there is no need to set up any additional config options. |
@microbit-carlos that's great! i was actually struggling on figuring out where to inject those options in our toolchain anyhow |
FYI, the codal version has been updated already via #6243, so this PR can be merged without having to change pxtarget.json. |
fixes #4381
see linked issue for the discussion here. swapping out our custom scaling for the scaling that's now built in to the ubit object
@microbit-carlos FYI