Clapping music: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
continuing [[sedsongs]]
... continuing from the [[sedsongs]] exercise


See [[Bash]] for help with loops & variables
See the page on [[Bash]] for help with using loops & variables


Template for midge, each channel is one of the parts.
This is an exercise to create a Bash version of [[wikipedia:Steve Reich]]'s [[wikipedia:Clapping music]] using Bash and a pipeline using midge and timidity.


To start, create the first two bars "by hand" as a midge file:
<source lang="text">
<source lang="text">
@head {
@head {
Line 16: Line 17:
         $octave 4
         $octave 4


    # the main pattern (3, 2, 1, 2 claps with rests in between)
     c c c r c c r c r c c r
     c c c r c c r c r c c r
    # the first performer simply repeats the pattern...
     c c c r c c r c r c c r
     c c c r c c r c r c c r


     }
     }
Line 26: Line 28:
         $octave 7
         $octave 7


    # the 2nd performer starts with the main pattern
     c c c r c c r c r c c r
     c c c r c c r c r c c r
    # .. and (eventually) shifts the pattern
     c c r c c r c r c c r c
     c c r c c r c r c c r c


     }
     }

Revision as of 14:16, 13 October 2010

... continuing from the sedsongs exercise

See the page on Bash for help with using loops & variables

This is an exercise to create a Bash version of wikipedia:Steve Reich's wikipedia:Clapping music using Bash and a pipeline using midge and timidity.

To start, create the first two bars "by hand" as a midge file:

@head {
    $tempo 120
    $time_sig 4/4
}
@body {
    @channel 1 {
        $patch 1
        $length 16
        $octave 4

    # the main pattern (3, 2, 1, 2 claps with rests in between)
    c c c r c c r c r c c r
    # the first performer simply repeats the pattern...
    c c c r c c r c r c c r

    }
    @channel 2 {
        $patch 2
        $length 16
        $octave 7

    # the 2nd performer starts with the main pattern
    c c c r c c r c r c c r
    # .. and (eventually) shifts the pattern
    c c r c c r c r c c r c

    }
}

The trivial bashified version, note the need to escape (backslash) the $s.

cat << END
@head {
    \$tempo 120
    \$time_sig 4/4
}
@body {
    @channel 1 {
        \$patch 1
        \$length 16
        \$octave 4

    c c c r c c r c r c c r
    c c c r c c r c r c c r


    }
    @channel 2 {
        \$patch 2
        \$length 16
        \$octave 7

    c c c r c c r c r c c r
    c c r c c r c r c c r c


    }
}
END
for ((i=0; i<13;i++))
do
done