This code randomises 12 tones into a structured prime, or original key.

Classical key scales are sequential, linear, determined by the proper intervals.

In the twelve-tone technique devised by Arnold Schoenberg, which I've adopted here, all 12 available notes are randomly arranged in the prime scale.

This prime is programatically transformed three ways: inverted, inverted reverse and reverse, as outlined below. Only the prime and reverse works at the moment.

- The row is a specific ordering of all twelve notes of the chromatic scale (without regard to octave placement).
- No note is repeated within the row.
- The row may be subjected to interval-preserving transformations -— that is, it may appear in
**inversion (I)**,**retrograde (R)**, or**retrograde-inversion (RI)**, in addition to its "original" or**prime form (P)**. - The row in any of its four transformations may begin on any degree of the chromatic scale; in other words it may be freely transposed. (Transposition being an interval-preserving transformation, this is technically covered already by 3.) Transpositions are indicated by an integer between 0 and 11 denoting the number of semitones: thus, if the original form of the row is denoted P0, then P1 denotes its transposition upward by one semitone (similarly I1 is an upward transposition of the inverted form, R1 of the retrograde form, and RI1 of the retrograde-inverted form).