Fractal music for violin solo

perl rnd=1234
The program generates a random series, based on the optional parameter, then makes a cyclic join. The notes of the join are assigned some simple, repetitive rhythm, e.g.
...  A♭  1/4  B  2/4  C  3/4  A  1/4   B♭  2/4  E♭  3/4  D  1/4  E  2/4   C#  3/4  F  1/4  F#  2/4  G  3/4  ...
Then it is repeatedly modified as follows:
  1. pick at random two adjacent tones, note the interval between them and their total duration.
    C# 3/4 F 1/4,   4 semitones apart, lasting 4/4
  2. find a segment in the cycle, which spans the same interval, and note its duration
    C  3/4  A  1/4  B♭  2/4  E♭  3/4   D  1/4  E  2/4,   which lasts 12/4
  3. replace the adjacent tones with their total duration, with the segment transposed, and proportional durations.

    What comes out (trust me with the fractions) is:

    ...  A♭  1/4  B  2/4  C  3/4  A  1/4   B♭  2/4  E♭  3/4  D  1/4  E  2/4
    C#  3/12   B♭  1/12  B  2/12   E  3/12  E♭  1/12   F  2/12  
    F#  2/4  G  3/4  ...

The total duration has not changed, and all the old notes are in place – but some blue notes   b♭ 1/12  b 2/12   e 3/12  e♭ 1/12   got inserted. In this case 1/12 is a simple triolet, but much messier subdivision may occur later, if, for instance, a segment replaces

F 2/12   F# 2/4
The program regularizes crazy subdivisions, and does not allow very short durations.


So what is fractal?


The three steps mentioned above are actually the standard fractal construction via affine transforms. If we map time and pitch on the two axes in the plane, the modified tune contains an affine transform of the segment from step 2. The blue graph is obtained from the green graph by translation (in x=time and y=pitch) , plus scaling (in x=time only) .


Blue replaces red;    blue starts and ends like red;    blue similar to green.