… Songs.hz / Reich

Right-click to copy examples to your workspace


This song is inspired by Steve Reich's Violin Phase.

The driver: reich.js

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

let songFile = "reich.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: reich.hz

This song comprises two Voices and two Tracks. Each track repeats phrase twice. And the phrase is just a 25 repetitions of 12 notes. The second track performs phrase at 99% of the speed of phase1 and this produces a hypnotic phasing effect. Note also, that phase2 changes Transpose and MidiProgram between phrase invocations. Both voices employ the FluidSynth instrument are configured following the General MIDI standard.

During performance, opening reich.hz will reveal that the individual notes are reflected by cursor changes within the text editor. Also, if you have the previewer visible (see the Settings menu atop the text editor) you can also watch the performance in the piano-roll formatted preview.

songs_hz:0.1.0
Song(Id:"Mr Reich")
{
    Tempo = 140

    // here's a musical phrase that will be performed by tracks.
    // note that pan's value depends on its track
    phrase = [e4 f#4 b4 c#5 d5 f#4 e4 c#5 b4 f#4 d5 c#5]!25

    Voice(Id:"v1")
    {
        AnodeInit = "FluidSynth"
        DisplayColor = "#34F"
        pa = (pa:<0.5,.0>)
        vo = (vo:<4,2.5,4,2.5,4>)
        // over a duration of 50 measures, sample artic 20 times
        // nb: because it's over a single stretched measure all
        // events are delivered_scheduled at the outset.
        [pa|vo!20]@50
    }
    Voice(Id:"v2")
    {
        AnodeInit = "FluidSynth"
        DisplayColor = "#3F4"
        Tempo *= .99
        // over a duration of 50 measures, sample artic 50 times
        artic = (pa:<.5,1,.5,1,.5,1,.5,1>,vo:<4,3,4>)
        [artic!50]@50
    }

    Track(Id:"phase1", Mute:0)
    {
        VoiceRef = "v1"
        MidiChannel = 1
        DisplayColor = "#34F"
        $[phrase]
        $[phrase]
    }
    Track(Id:"phase2", Mute:0)
    {
        VoiceRef = "v2"
        MidiChannel = 2
        Tempo *= .99
        DisplayColor = "#3F4"
        $[phrase]
        Transpose = -12
        MidiProgram = "violin"
        $[phrase]
    }
}

Here's what you see if you Toggle Previewer in the CodeEditor. Notice the effect of Transpose on the second phrase of track phase2. This also coincides which the MidiProgram change and the introduction of the violin voice.

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