Given a melody, it builds several voices based on a harmoniztion of the melody. When music plays, the melody may be omitted – a true enigma.

The instruction:

perl  drenig.pl   file_lhom     rand_345     dur_100     with      orc
will produce a score named  enig345  and the corresponding midi file  enig345.mid.

All the parameters except the first are optional. Their interpretation is as follows:

Must appear; scorename is the name of the file to be processed by tondur.

The number seed is used to initialize the random numbers generator.

the larger the value, the longer the piece. Duration is increased by repeating the "enigma" tune.

if specified, the enigma tune will be sounded with the other voices. If omitted, the enigma tune will not be heard.

if specified, the voices will be assigned to various instruments; if omitted, they are all played on the piano.
The piano score may be unplayable by one pianist – then assume a player piano, or piano four hands, or two pianos.
The driver program executes two other programs:
  1. tondur.pl

    The instruction is:

    perl  tondur.pl   file_scorename
    This reads a score and prepares the input for
    enig.pl , the file ouou.txt. It takes one obligatory parameter, the name of the input score.


    input:      lhom    (L'Homme Armé)
    {L'Homme Arme}
    key 1b
    names drm
    s5 /2 s/4 d/2 d/4 i l/2 s 3/4 r5 /4 r s5 p r6 r  r d/2 i/4 l/2
    s 3/4 r6 /4 r r s5 3/4 s6 /2 s/4 f/2 f/4 s/2 s/4 r 3/4 s6 /2 s/4 f/2 f/4 
    s/2 s/4 r/2 s/4 l/2 s/4 f m/2 r 3/4 p  s5 /2 s/4 d/2 d/4 
    i l/2 s 3/4 r5 /4 r s5 p r6 r  r d/2 i/4 l/2 s 3/4

    output:      lhomn0
    67 1/2
    67 1/4
    72 1/2
    72 1/4
    70 1/4
    69 1/2
    67 3/4
    62 1/4
    62 1/4
    67 1/4
    -1 1/4
    74 1/4
    74 1/4
    74 1/4
    72 1/2
    70 1/4
    69 1/2
    67 3/4
    The file inin.txt may contain key instructions (in this case key specifies 1 flat) and names instructions ( in this case, d r m ... = Do Re Mi ... = C D E ... ; rest is p). The program also recognizes comments: text in braces, both braces on the same line, text may not contain braces. Tones and duration may be specified as in my usual music editor, except that + and –  are not available for octave, and fractions cannot be written as numerator only.

  2. enig.pl

    This program

    • receives its parameters from the driver
    • reads the file ouou.txt prepared by tondur.pl
    • analyzes the input, to determine the key of the piece – any of the keys that contain all the notes of the "enigma" melody. If no standard key fits, the program will use all the 12 (semi)tones.
    • writes the score.