💾 Archived View for thrig.me › blog › 2024 › 06 › 04 › canon.gmi captured on 2024-08-18 at 18:17:37. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-06-16)

-=-=-=-=-=-=-

Canon Construction

Gemini lacking in music markup support (for better or worse) may make this difficult, but here we present a minimal canon in two voices.

    soprano | R G G G G ...
    alto    | C C C C ...

That is, the alto or lower voice always hits "C" (sometimes 261.63 Hertz) and after some delay the soprano or higher voice always hits "G" (392 Hz, say) above the "C". "R" is for rest, or silence. Is this a canon? Here some will say no; the case is similar to asking whether a virus is alive. Kinda, sorta, maybe, no? Various forms of a canon are observed: there are multiple voices; the voices enter after one another at some distance; the voices are transposed from one another by some amount, here by a fifth. Complicating matters is that there are other forms of canon that do not observe some or all of the prior; crab canons are a voice played against that same voice played backwards. Generally canons have more musical variety than hitting the same note or notes over and over, just as "being alive" may have more complications than a virus does. This gets into "I'll know life, or a musical canon, when I see it" territory and virus or a fifth offset by one beat may well not pass that bar.

    soprano | R E C C
    alto    | C C E R

Technically the above is a crab canon, though most any music professor would flunk the effort, and it probably will not wow any audience. The form is observed; the two voices are the reverse of the other. A traditional way to play a crab canon was to have musicians reading from a sheet of music on the table between them, one reading bottom to top, and the other top to bottom, though the directions are relative to a particular musician.

How about a canon in three voices?

    soprano | R R R R C C C C ...
    alto    | R R G G G G ...
    tenor   | C C C C ...

This one innovates (a likely abuse of that term) by starting the new voices two rests in, or four rests for the third and last voice to enter. The transposition value between the voices varies; adding another fifth to the "G" would be playing "C" "G" and "D" together which is a suspended chord, or a dissonance not acceptable to traditional forms of counterpoint. So instead the third voice transposes by a 4th instead of a 5th from the prior voice, or by an octave from the original voice. Which voice enters first and the order in which the voices enter and their transposition can vary; for simplicity the above always have the lowest voice entering first, then the next highest voice, etc. The transposition values and their range are typically limited as one may not want the voices too far apart, and the transpositions are restricted both by the range and the need for consonance between the voices. Unless you are breaking those rules; other ideas here are to chop the canon up and present it in various orderings, but that is a bit more advanced, and you probably need to be able to write simpler canon before going wild with the form. Competence before comprehension, as some might say.

At some point a canon (but not a crab canon, and maybe not a spiral canon) loops back around to the beginning; the above have used "..." to indicate that the looping back around could happen anywhere as there is not enough note variety to make that matter. Repeating the same note is too little variety. An opposite of only one note is random note selection from a larger set, which will usually (but not always) be bad, but for different reasons. A scale to select from follows. There are other scales and tunings, but these are typical in the modern Western tradition.

    Note  Pitch  Frequency (Hz)
    A     57     220.00
    B     59     246.94
    C     60     261.63
    D     62     293.66
    E     64     329.63
    F     65     349.23
    G     67     392.00
    A     69     440.00

Dice could be rolled to select notes, or with a computer a program can generate and offset the melody.

    ; canon-random.lisp - make a random melody and play that against itself
    (require :asdf)
    (asdf:load-system :smolmidi)   ; https://thrig.me/src/smolmidi.git
    (block nil (setq *random-state* (make-random-state t)) (return))

    (let ((pitches '(57 59 60 62 64 65 67 69)))
      (defun random-pitch ()
        (nth (random (list-length pitches)) pitches)))

    (defun play (track duration pitch &key (velocity 96) (offset 0))
      (smolmidi:note-on track offset pitch velocity)
      (smolmidi:note-off track duration pitch 0))

    (let (pitch-list)
      (defun melody (&key (length 16) (offset 0) (duration 96) (transpose 0))
        (unless pitch-list
          (setf pitch-list (loop repeat length collect (random-pitch)))
          (format t "~&~a~&" pitch-list))
        (let ((track (smolmidi:new-track)))
          (play track duration (+ transpose (first pitch-list))
                :offset (* offset duration))
          (loop for pitch in (rest pitch-list) do
                (play track duration (+ transpose pitch)))
          track)))

    (smolmidi:write-midi-file
      "out.midi" (list (melody)
                       (melody :offset 4 :transpose 12)))

canon-random.lisp

Odds are, the result will be bad, lacking in any sort of melodic line that humans have been trained for over many years of exposure. Also the melodic line will most likely not pair well when offset against itself, most likely regardless of the offset used.

    $ sbcl --script canon-random.lisp
    (59 65 67 69 62 62 67 62 59 64 62 65 62 60 67 57)

random.midi

    R R R R B F G A D D G D B E D F D C G A
    B F G A D D G D B E D F D C G A . . . .

The initial offset is four, and the second voice is transposed up by an octave (12 semitones). The first few note pairings are okay, but then there's a dissonant E with a D, and then a D below a G, though composers have varied as to whether this fourth is considered dissonant, or not.

To continue this canon, the four "." in the starting line will need to be filled in with something, and then if we repeat the canon one or more times the four "R" in the following line will also need to be filled in with something. These sections, marked below with "x y z q", are where the two voices overlap when looping around the other.

    R R R R B F G A D D G D B E D F D C G A x y z q B F G A D D G D B E D F D C G A ...
    B F G A D D G D B E D F D C G A x y z q B F G A D D G D B E D F D C G A x y z q ...

The "x" used must be the same in each voice, and must also be consonant with the "D" above it or the "B" below it, and same for the y, z, and q. Depending on what notes are considered consonant this will restrict the available note choices, and may result in situations where nothing works, in which case one will need to backtrack and rework the original melody (this is pretty common). The demand for consonance can be relaxed somewhat through the suitable use of suspensions that sustain a prior note and resolve it by stepping downwards, among other allowances for dissonances, particularly when the number of voices involved increases. Much has been written about counterpoint and melodic design, elsewhere.

A quick way to consider consonance is to pick a note, say "D", and then list the notes that can be placed below it (any other "D", "G", or "B", range permitting) and above it ("D", "F", "A", "B"). Some composers, again, also allow for "G" above a "D", while others do not. Check with your local tradition for details. Which note pairings are best, or at least work, will have to be learned by practice, or you could have some algorithm do the counterpoint for you (David Cope has done automation in this space).

Here is another simple canon that at least varies the pitches. It uses consonant intervals between the voices, and the octaves are approached by contrary motion to help keep the voices distinct from one another. Other musical traditions are less concerned about so-called parallel octaves (or fifths).

    soprano |R R|C D E D|C D E D|C D E D|C D E D|...
    alto    |C D E D|C D E D|C D E D|C D E D|...

canon-cded.lisp

cded.midi

Maybe it could be used as a backing track for something more complicated? Anyways, that's probably enough about canon to make the reader dangerous at them. (And you'll probably want to learn some more about counterpoint and dissonance handling, elsewhere, too.)

P.S. the "spiral canon" mentioned above is something like a harmonic sequence that is repeated at some transposition from where the previous pattern started, so maybe a third higher or a second lower. This will run into range limits at some point so cannot go on forever. The important point here is to make the step into the next iteration work, in addition to having something not terrible to repeat between the transpositions.