… Songs.hz / Perpetuum

Right-click to copy examples to your workspace


This song is a transcription of the Penguin Cafe Orchestra tune, "Perpetuum Mobile".

The driver: perpetuum.js

The driver javascript constructs the path to the song file then loads it by constructing a Songbook instance.

let songFile = "perpetuum.hz";
let thisDir = path.dirname(this.GetFilePath());
let presetDir = thisDir;
let songPath = path.join(thisDir, songFile);
let str = await FetchWSFile(songPath, false/*not binary*/);
let songbook = new Songbook(str, songFile); 
for await (const val of songbook.PerformSong(this, presetDir, 0))
    yield;

The song: perpetuum.hz

This example highlights the use of Sequencer to arrange a song.

First we establish global settings in the Song block:

Song(Id:"Perpetuum Mobile")  // by Penguin Cafe Orchestra
{
    introTempo = 66
    introTempo2 = 168 // quarter
    themeTempo = introTempo2 // quarter
    themeTempo *= 2
    Velocity = <?.6, .85>
    // ...
}

Next we define the Sequencer. Unlike Song, Section, Voice, Track, Sequencer is not a block, but rather a single global value that governs the performance of Sections defined in other blocks. Note also that we employ ! to repeat song sections.

Sequencer = [ 
    intro 
    theme1a theme1b!2 
    theme2!2 
    theme3a theme3b!2
    theme4a theme4b!2 
    theme5a theme5b!2 
    theme6a theme6b!2 
    theme7a theme7b!2 
    theme8a theme8b!2 
    theme1b!2
    theme2a theme2b!2 // differs from 2 in lh
    fin
] 

This song comprises three Tracks. The first track, "timing", establishes global per-section values for Meter and Tempo. Below is its intro section. Note that we can change Tempo within a section by tracking time with the combination of rest (z) measures.

Track(Id:"timing", Scope:"Global")
{
  Section(Id:"intro")
  {
    Meter = <2, 4>
    Tempo = introTempo
    [z]!10
    Meter = <3, 4>
    Tempo = introTempo2
    [z]!2
  }
//...

The other two tracks represent the left and right hands of the composition for piano. Each employs the default instrument (FluidSynth) with two different MIDI Channels depicted with two different colors.

Within each track there are track-specific Section definitions. Here's "theme1a" from the track, "LH".

// 15/8
Section(Id:"theme1a")
{
    DisplayColor = "#3a6"
    [e3 c3 g3 c3  a3 c4 c4  e3 c3 g3 c3  d3 c3 b2 c3]
}

We can change display colors for sections or measures to aid in visualizing in the song previewer that can be found in the editor windows associated with perpettum.hz. The previewer visibility can be toggled with the settings menu or via hotkeys. Here's what it looks like:

More details can be found here.

home .. topics .. interface .. reference .. examples .. tipjar