Open microbit-carlos opened 2 months ago
PR created in codal-core:
MakeCode and MicroPython already use this value, so it shouldn't have an impact there
Previous discussion:
When LEVEL_DETECTOR_SPL_8BIT_000_POINT
was introduced it was set to 35.0, but the default value for LevelDetectorSPL.minVal
was already set to 52.0, so with the default values LevelDetectorSPL.getLevel()
would have never return a value below 52 dB:
However, at that time, the uBit.audio.levelSPL
constructor in codal-microbit-v2 was setting minVal
to 0, it was only changed to 52.0 a year later, so until then uBit.audio.levelSPL->getValue()
could return values lower than 52.0, and that explains why earlier measurements could detect 35-40ish dB:
https://github.com/lancaster-university/codal-microbit-v2/commit/02a85fa86a00ac204cbd2a4caacd5a964e1cf26e
Because the
LevelDetectorSPL
minVal is set to 52: https://github.com/lancaster-university/codal-microbit-v2/blob/bd446c49f5501584e2cef3b5f53ebb826928e47b/source/MicroBitAudio.cpp#L82And
LevelDetectorSPL
will clamp the lower end of thelevel
value tominVal
: https://github.com/lancaster-university/codal-core/blob/509086cc8590465041b15493ab52b56e7071c110/source/streams/LevelDetectorSPL.cpp#L142-L147