Compose

Play

Transpositions

Initially, the line is transposed by a certain amount. A transposed note may lie outside the prescribed range, in which case it is transposed up or down, as needed, by an octave. It is also possible that the transposed note does not belong to the scale, in which case it is raised by a semitone.
The tests for range and scale are then repeated. Since the ranges are at least 20 semitones wide ( minor 13th ) the repetitions do eventually stop, and all
constraints are satisfied.

Variations

All the variation preserve total duration, since they must agree with the basses and the rhythm section (drums).
A line may be varied by 2 methods:
  1. scale filling
    A skip in the line is replaced by a scale segment, starting and ending with the original pitches. The durations start as equal, but will be always adjusted to
    simple durations.

    For instance :

    • if the scale is: C D E F G A♭ A B♭
    • and the melodic gap is F 3/8  B♭ 1/8 , with total duration 4/8 = 1/2
    • then the filling is F 1/10  G 1/10  A♭ 1/10  A 1/10  B♭ 1/10 still lasting 1/2
    • since 1/10 is not a simple duration that will be replaced by, e.g.
      F 3/8  B♭ 1/8  →  F 1/12  G 1/12  A♭ 1/12  A 1/8  B♭ 1/8
      the first 3 notes in a triolet, and the total duration preserved.

  2. bridging
  3. Suppose there is a a gap in the melodic line which rises a perfect fourth, and there is among the bridges one that also rises the same interval (perfect fourth). Then the gap is replaced by the bridge tranposed, so its 1st and last pitches match the original pitches. In addition, the original total duration is subdivided, so it is proportional to the durations in the bridge.

    For instance :

Both bridging and scale fill may be repeated.

Constraints

These constraints are implemented by the routines tosc , toscu .

Inversions

To invert a melody, find the highest and the lowest note and compute their sum . Then replace
note  →  sum - note
( The numeric values of notes are part of the MIDI encoding:
60 = middle C

Then:
57 = A below middle C
58 = A# = B♭ below middle C
59 = B below middle C
60 = middle C
61 = C# = D♭ above middle C
62 = D above middle C
         etc. )

If you're willing to do the arithmetic, convince yourself that the inversion of :
C  B♭  D  E  F  A♭            ( B♭ below C, all the others above )
is:
F#  A♭  E  D  C#  B♭
Notice how the lowest and highest notes swapped position – obviously. Then all these pitches may change in order to fit the scale.

Simple durations

These are dyadic fractions, 1/2, 1/4, 1/8, 1/16, ... respectively 3/4, 3/8, 5/8, ... 3/16 etc...
plus simple triolets: three equal durations, lasting together 1/2, 1/4, 1/8, 1/16, etc...
Any other durations are converted into simple durations by the routines
dureg, balans, conservedur, neardur, quarters, regv, adspread and subspread.