Block Code Music Unblocked

Write a melody with code blocks, learn functions by reusing phrases, and layer voices into a round.

Block Code Music is a coding puzzle where your program plays a song instead of moving a character. A small staff on the left shows the target tune as gray notes. You snap note blocks together, press Run Program, and the notes turn black one by one as your melody plays. The tune is “Frère Jacques,” the familiar round.

The real subject here is functions. By the end you will understand why programmers give a chunk of code a name so they can reuse it.

The goal

Every level asks you to match the melody on the staff. When your notes line up with the target, the game shows the JavaScript your blocks produced and offers the next level. Levels one through nine have a target. Level ten drops the target entirely so you can write your own music.

Building a tune

All code goes inside a “when Run clicked” block. Drag in a “play note” block, click its note name to choose a pitch on a mini staff, and click the note symbol to set how long it lasts. You can also type a pitch such as C4 and press Enter.

The first level wants four notes: C4, D4, E4 and C4. Level two asks you to play those four notes twice without adding more note blocks. The only way is to place them inside a function and call it two times. From there, each new phrase gets its own function until the whole song is done.

New blocks along the way

Once the melody is finished, the toolbox keeps growing. An instrument block lets you swap the piano for a choir, flute, violin, guitar, banjo, trumpet or drum, each played from real recordings. A rest block adds a pause. The last target levels give you several start blocks that run together, so you can hold each voice back and stack them into a four-part round.

Strategy notes

Give each function a clear name, like “part one” and “part two,” and the program will read like a score. If the game says your answer could be improved, it means you repeated note blocks that belong in a function.

Watch for the phrase that ends on a held note, and lengthen that one note rather than adding a second block. For the round, rest blocks control how late each voice comes in. Giving every voice a different instrument also makes the layers easier to tell apart, and the tempo slider lets you slow everything down while you hunt for a wrong note.

Controls

ActionKeyboardMouseTouch
Add note, rest or function blocks—Click the Music category and drag a block into the workspaceTap the category and drag a block
Choose a pitchType a note name such as D4 and press EnterClick the note name and pick a line on the small staffTap the note name and pick a line
Choose a note length—Click the note symbol on the blockTap the note symbol
Play or stop your tune—Click Run Program, then ResetTap Run Program, then Reset
Change playback speed—Drag the tempo sliderSlide the tempo control

Block Code Music FAQ

Does Block Code Music work on a tablet or Chromebook?

A Chromebook or laptop is the smoothest option, since you can drag blocks with the trackpad and type note names like D4 straight into a block. On a tablet you can drag and tap blocks, but the workspace and staff need a fair amount of screen room.

Do I need to read music to play?

Not really. Gray notes on the staff show the target tune, and your program fills them in black as it plays. If a note lands in the wrong spot, you can see the gap right away and fix the pitch or length.

How many levels are there?

Ten. The first nine have a target melody to match, and the tenth is open composing where you write anything you like with the full set of blocks.

Is there sound right away when the page loads?

No. The page stays silent until you press Run Program, and Reset cuts the music off straight away, which makes it easy to use in a classroom.

More games like Block Code Music

All puzzle games →