Closed microbit-carlos closed 3 years ago
New behaviour
This makes the pin argument mostly redundant, but kept for compatibility and the subtle case that you're, say, playing on pin2, and call stop on pin1 (speaker will stop in any case).
@dpgeorge did the stop behaviour described here get implemented in the end?
did the stop behaviour described here get implemented in the end?
No. The current behaviour is simply that, whether or not music.stop()
is given a pin argument, it stops the music and disconnects whatever pin was used from the mixer (hence also stopping all other sounds like expressions on that pin). The speaker stays connected though.
You can test this behaviour with:
music.play(music.NYAN,wait=0); audio.play(Sound.HAPPY); sleep(50); music.stop()
(that will play music for 50ms then stop it, but the HAPPY will continue, on the speaker)
pin argument: stop on speaker and that pin if playing, do not stop on other pins
This is not really possible to do with the current CODAL, because you can only play on one pin at a time (in addition to the speaker).
This issue is affected by the outcome of #50, so maybe that needs to be resolved first?
This was implicitly fixed as part of #50 : music.stop()
now only stops any ongoing sequencing of notes, it does not disconnect any pins.
The following test should now work as expected, the music stops but the sound expression continues (on both the internal speaker and external pin0):
music.play(music.NYAN,wait=0); audio.play(Sound.HAPPY,wait=0); sleep(50); music.stop()
For completeness, this is the commit that addressed the issue here: 6790bb511b7966e727c147ff27269121e340435f
The
music.stop()
function can take a pin argument likeplay()
.Does it currently correctly process tuples? It doesn't throw an error, but don't know if it works as expected. Technically in this case the user could also do
music.stop(pin=pin_speaker)
andmusic.stop(pin=pin0)
to stop the music in both pins, but it does make sense to mirror play.I guess my question is how having music play over multiple pins is going to interact with the stop function. Will it work when doing
play(..., pin=(pin_speaker, pin0))
and then we only want to stop a single pinmusic.stop(pin=pin0)
?This on the REPL currently stops the music playing in the speaker
Another thing to consider for https://github.com/microbit-foundation/micropython-microbit-v2/issues/30 as well.