Skip to content

stringPlayable's specifications are easily missed/ignored, and maybe misleading #6664

@martinwork

Description

@martinwork

Describe the bug
Arising from support ticket https://support.microbit.org/a/tickets/94149 (private)

Related: #6603

The support ticket is about coding in JavaScript and points out that note D5 sometimes sounds an octave low.

music.play(music.stringPlayable("G4 A4 C5 A4 C5 D5 - -", 120), music.PlaybackMode.UntilDone)
music.play(music.stringPlayable("D5 - - - - - - -", 120), music.PlaybackMode.UntilDone)

It turns out that stringPlayable changes the next note after C5 to be explicitly octave 4.

stringPlayable's tooltip says "up to eight notes [C D E F G A B C5] or rests [-] separated by spaces".

It's easy to miss that this really means only eight notes, and only C5 or 4th octave notes, with no sharps flats, octave numbers or durations.

It's easy to ignore because stringPlayable works more generally, so long as it doesn't include the exact note "C5". Workaround: change C5 to C55 or C5:4, for example.

Is the tooltip and the help wrong?
https://makecode.microbit.org/reference/music/string-playable

It's not obvious (is it supported?) that it's possible to replace the melody editor with a text block, although a round trip to JavaScript mode, tends to revert to the melody editor showing "invalid".
https://makecode.microbit.org/_aCxgiR6pAHDx
Image

Would a separate feature be useful, like https://makecode.microbit.org/_FfRTkg2wq5AT?
Image

In stringPlayable, C5 simply adds "4" to the next note, so can generate surprises. Example https://makecode.microbit.org/_7HD0dUibbJxR shows that "D5 C5 D C5 D5 C5 C:2" is converted to melody string array [ "D5", "C5", "D4", "C5", "D54", "C5", "C:24"]

Using string[] directly is very clunky.
music.play(new music.StringArrayPlayable(["G4:4", "A", "C5", "A4", "C5", "D", "R", "R", "G4"], undefined), music.PlaybackMode.UntilDone)
https://makecode.microbit.org/_Aw72ho7PR6jd
Image

Is there a compact way to store a tune in flash, and play it without converting to a different format in RAM?

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions