[net.music.classical] All-interval-row program in VAX pascal

janzen@sunfun.DEC (Thomas E. Janzen CSS GNG CWO 714 850-7849 SUNFUN::JANZEN) (08/17/84)

PROGRAM All_Interval_Row(INPUT,OUTPUT);
{-----------------------------------------------------------------------}
{  On 16 August 1984 this program seems to work a little.  It will print}
{  out some numbers, then seem to stop.  Control-Y at this point and    }
{  copy down the numbers.  Run the program over and over until you get  }
{  a single run that prints 10 decimal digits.  then fill in the missing}
{  pitch (1 to 11).  It may or may not be an AIR, check it manually.    }
{  My run was OK.                                                       }
{  the numbers represent pitches.  For example, 0 could be A, 1=A#,2=B, }
{  3=C,4=C#,5=D,6=D#,7=E, etc.  Note that the first pitch in each row   }
{  is 0 (zero), so it isn't printed out.   Lots of luck.                }
{  Thomas E. Janzen  15 August 1984                                     }
{                                                                       }
{  OUTPUT: A twelve-tone pitch class set containing all intervals of    }
{          the Western dodecuple scale.                                 }
{                                                                       }
{  PROCESSING: A search and assembly of a twelve-tone pitch class set.  }
{_______________________________________________________________________}
CONST
  Tritone = 6;
TYPE
  Row = ARRAY [0..11] OF INTEGER;
  Truth_Table = ARRAY [0..11] OF BOOLEAN; 
VAR
  Pitch_is_Old,
  Interval_is_Old
  : BOOLEAN;
  Random_Number,
  Counter
  : INTEGER; 
  Pitch_Class_Set, 
  Interval_Set {Note that Interval_Set[n] is the interval between
                Pitch_Class_Set[n-1] and Pitch_Class_Set[n].}
  : Row;
  Intervals_Used,
  Pitches_Used 
  : Truth_Table;
PROCEDURE Write_the_Set(Number_Set : Row );
{-----------------------------------------------------------------------}
{  INPUT:  An array of 12 integers to write out                         }
{  OUTPUT: A print-out of the array of integers, with index 0 to 11.    }
{_______________________________________________________________________}
VAR
  Index : INTEGER;
BEGIN
FOR Index := 0 TO 11 DO
  WRITELN(Index, Number_Set[Index])
END;
FUNCTION Interval_Size(Set_of_Integers : Row;
                       Current_Pointer : INTEGER) : INTEGER;
{-----------------------------------------------------------------------}
{  INPUT:  A set of 12 integers and an index.                           }
{  OUTPUT: The equivalent musical interval between                      }
{          Set_of_Integers[Current_Pointer]    and                      }
{	   Set_of_Integers[Current_Pointer - 1].                        }
{_______________________________________________________________________}
VAR
  Temp_Num : INTEGER;
BEGIN
Temp_Num := Set_of_Integers[Current_Pointer] - 
                 Set_of_Integers[Current_Pointer - 1];
IF (Temp_Num < 0) THEN Interval_Size := 12 + Temp_Num
  ELSE Interval_Size := Temp_Num
END;
{-----------------------------------------------------------------------}
{                                                                       }
{                     M A I N   P R O G R A M                           }
{                                                                       }
{_______________________________________________________________________}
BEGIN { Main Program }
FOR Counter := 0 TO 11 DO
BEGIN {Initialize arrays.}
  Pitches_Used[Counter] := FALSE;
  Intervals_Used[Counter] := FALSE;
  Pitch_Class_Set[Counter] := 0;
  Interval_Set[Counter] := 0
END;
Interval_Set[0] := Tritone;
Pitch_Class_Set[11] := Tritone; {The last tone in any AIR will always be a }
                                {tritone away from the first tone.}  
Intervals_Used [Tritone] := TRUE; {The tritone has been used in the set.}
Pitches_Used[Tritone] := TRUE; {The tritone has been used in the set.}
Pitches_Used[0] := TRUE; {The first note.} 
FOR Counter := 1 TO 11 DO
BEGIN
  Pitch_is_Old := TRUE;
  Interval_is_Old := TRUE;
  WHILE Pitch_is_Old OR Interval_is_Old DO
  BEGIN
    Random_Number := (CLOCK DIV 2) MOD 12;
    Pitch_Class_Set[Counter] := Random_Number;
    {Check that this pitch has not been used.}
    Pitch_is_Old := Pitches_Used[Pitch_Class_Set[Counter]];
    {Check that this interval has not been used.}
    Interval_is_Old := Intervals_Used[Interval_Size(Pitch_Class_Set,Counter)]
  END;
  Pitches_Used[Pitch_Class_Set[Counter]] := TRUE;
  Intervals_Used[Interval_Size(Pitch_Class_Set,Counter)] := TRUE;
  WRITELN(Pitch_Class_Set[Counter])
END;  
Write_the_Set(Pitch_Class_Set)
END.

Thu 16-Aug-1984 12:12 PDT