Let’s synthesize vocal part of “Twinkle twinkle little star” using the following score. We code the second measure and after. When the first note is not a rest, an empty measure with a rest will be automatically inserted at the beginning.
Step 1. Prepare a scratch project file (.sb2)
Create a scratch project with lyrics and a melody line. You can refer to or copy a sample project here.
Note that the name of the sprite needs to be “song”.
Use a pair of “Say …” and “play note … for … beats” for a sound.
Use “rest for … beats” for a rest.
Use preset variables for duration.
Use hyphen to connect multiple syllables.
“twin-“ + “kle”
“lit-“ + “tle”
“won-“ + “der”
One note cannot cross over a bar line between measures.
Save/download the scratch project as a sb2 file.
Scratch offline editor can also be used after downloading sb2 file.
Step 2. Convert the scratch project file (.sb2) to MusicXML (.xml)
In “song” sprite, variable “beginning-silent-duration” is used to adjust start timing. However, “Song” sprite has some delay especially when many blocks exist.
Sprite “Giga” uses “timer”. So it is synchronized precisely with the song (wave file).