Jump to content
  • Sign in to follow this  

    Lesson 4. Rhythm, Repeats and Random Seeds



    The instruction to repeat is one of the most common and necessary in composing music. Here is the function GEN-REPEAT set to repeat pitches 5 times.


    This is the output:


    => (c4 cs4 fs4 g4 c5 c4 cs4 fs4 g4 c5 c4 cs4 fs4
        g4 c5 c4 cs4 fs4 g4 c5 c4 cs4 fs4 g4 c5)


    Sadly, we can’t see the repeat grouping that easily. It’s just one long list! There are no bar lines or divisions in the output. But there is a way of indicating bars coming up in Lesson 5.

    Both right and left hands of the piano are playing identical material BUT the right hand has been processed with LENGTH-WEIGHT.


    (length-weight '(3 1) lengths :weight '(3 1):seed 23) 
    => (-1/8 -1/8 1/8 1/8 1/8 1/8 1/8 1/8 -1/8 1/8
         1/8 1/8 -1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8
         1/8 1/8 -1/8 1/8 -1/8)


    You can see the LENGTH-WEIGHT replaces previously 'sounding' lengths with rest-lengths throughout the stream of pitches. The ratio used is (3 1), which indicates roughly 3 sounding lengths to 1 rest. Meanwhile the bass part in the left hand plays steadily each pitch of the repeated figure.


    Notice that the LENGTH-WEIGHT expression carries a keyword :seed


    (length-weight lengths :weight '(3 1) :seed 23)


    Without this seed, each time the function was evaluated a different weighting of rest-lengths to note-lengths would be given. Experiment with evaluating the expression without the seed, or simply change the seed itself to see how the output is effected.


    (setf pitches (gen-repeat 5 '(c4 cs4 fs4 g4 c5)))
    (setf transposed-pitches (gen-repeat 5 (pitch-transpose -24 pitches)))
    (setf lengths (span pitches '(e)))
    (setf lengths-rests (length-weight lengths :weight '(3 1) :seed 23))
    (setf piano-righthand
           :length lengths-rests
           :pitch pitches
    (setf piano-lefthand
           :length lengths
           :pitch transposed-pitches
           :velocity '(f)))
    (setf timesigs (get-time-signature lengths))
    (def-score lesson-4
               (:key-signature 'chromatic
                :time-signature '(5 8)
                :tempo 100
                :layout (piano-layout 'piano-rh 'piano-lh))
       :omn piano-righthand
       :channel 1
       :sound 'gm
       :program 'acoustic-grand-piano)
       :omn piano-lefthand)


    Screen Shot 2017-12-04 at 21.09.14.png


    Next page Lesson 5. List Processing

    Go to the Reference page.

    Sign in to follow this