pxt-common-packages
Version:
Microsoft MakeCode (PXT) common packages
34 lines (20 loc) • 904 B
Markdown
Show the melody editor and return the composed melody string.
```sig
music.melodyEditor("");
```
In Blocks, the melody editor is displayed and the user can create a melody using the melody editor interface. The composed melody is returned as a melody string for use with **playMelody**.
When not using Blocks, the **melody** string parameter is returned.
* **melody**: a [string](/types/string) which contains the notes of the current melody.
* a [string](/types/number) that contains the new melody created in the melody editor or the string in **melody** when the melody editor is not displayed.
Change the melody in **playMelody** using the melody editor.
```blocks
forever(function () {
music.playMelody(music.melodyEditor("E F G F E G B C5 "), 120)
})
```
[](/reference/music/play-melody)