microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
41 stars 22 forks source link

Playing a `microbit.Sound` or `audio.SoundEffect` crashes beta.2 #124

Closed microbit-carlos closed 1 year ago

microbit-carlos commented 1 year ago

To replicate:

from microbit import *

audio.play(audio.SoundEffect())
display.show("A")
from microbit import *

audio.play(Sound.HAPPY)
display.show("A")

In both cases the sound will play, but it will get stuck playing the last tone and play that indefinitely, never reaching the line to display "A".

Looks like it was introduced by this CODAL commit: https://github.com/lancaster-university/codal-microbit-v2/commit/31095d5d9f3c1ffc524c2777173d10fe7ee9ab25

More info in:

microbit-carlos commented 1 year ago

To have a working MicroPython hex for the Python Editor, we'll see tomorrow to maybe create a new CODAL tag with the commit reverted, or maybe go back in MicroPython to CODAL v0.2.40.

dpgeorge commented 1 year ago

This will block #118, #119, #122 (which require features from CODAL 0.2.40).

microbit-carlos commented 1 year ago

Okay, we've got a hotfix patch to resolve this and I'll release beta.3 right away.

The commit reverted was to solve a issue with the uBit.audio.soundExpressions.play() function returning before the sound finished playing (about 15ish ms or so), so it should be safe to revert:

Thanks @JohnVidler!