But if this works...major labor saver.
Code: Select all
#!/usr/bin/perl
@row={};
print "Enter tone row/series, one at a time. Sharps only, represented as '-s;' e.g. Cs.\n";
for($i=0;$i=11;$i++){
push(@row, <>); ##Entering Row.
}
%notes=( ##Establishing Notes to Numbers.
C=>0,
Cs=>1,
D=>2,
Ds=>3,
E=>4,
F=>5,
Fs=>6,
G=>7,
Gs=>8,
A=>9,
As=>10,
B=>11,
);
%pitches=( ##Establishing the commutative property.
0=>C,
1=>Cs,
2=>D,
3=>Ds,
4=>E,
5=>F,
6=>Fs,
7=>G,
8=>Gs,
9=>A,
10=>As,
11=>B,
);
$value=NULL;
foreach $note (keys %notes){
if ($note=~ m/row[0]/){
$value=$note;
%notes=(%notes, $note, 0);
}
}
foreach $note (keys %notes){
%notes=($note,($notes{$note}+12-$value)%12); ##Changing the values for the actual row
}
%series=();
foreach $tone(@row){
$series{$tone}=$notes{tone}; ##Making the Series
};
%series1=(); ##P1
%series2=();
%series3=();
%series4=();
%series5=();
%series6=();
%series7=();
%series8=();
%series9=();
%series10=();
%series11=();
@numseries=();
foreach $note (keys %series){
push(@numseries, $series{$note});
}
foreach $note (keys %series){
$series1{$series{$note}}=$pitches{$series{$note}+(12-$numseries[1])};
$series2{$series{$note}}=$pitches{$series{$note}+(12-$numseries[2])};
$series3{$series{$note}}=$pitches{$series{$note}+(12-$numseries[3])};
$series4{$series{$note}}=$pitches{$series{$note}+(12-$numseries[4])};
$series5{$series{$note}}=$pitches{$series{$note}+(12-$numseries[5])};
$series6{$series{$note}}=$pitches{$series{$note}+(12-$numseries[6])};
$series7{$series{$note}}=$pitches{$series{$note}+(12-$numseries[7])};
$series8{$series{$note}}=$pitches{$series{$note}+(12-$numseries[8])};
$series9{$series{$note}}=$pitches{$series{$note}+(12-$numseries[9])};
$series10{$series{$note}}=$pitches{$series{$note}+(12-$numseries[10])};
$series11{$series{$note}}=$pitches{$series{$note}+(12-$numseries[11])};
}
print " I0 I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 ";
print "P0", join(" ",@row), "R0\n";
print "P1", join(" ",%series1), "R1\n";
print "P2", join(" ",%series2), "R2\n";
print "P3", join(" ",%series3), "R3\n";
print "P4", join(" ",%series4), "R4\n";
print "P5", join(" ",%series5), "R5\n";
print "P6", join(" ",%series6), "R6\n";
print "P7", join(" ",%series7), "R7\n";
print "P8", join(" ",%series8), "R8\n";
print "P9", join(" ",%series9), "R9\n";
print "P10", join(" ",%series10), "R10\n";
print "P11", join(" ",%series11), "R11\n";
print " IR0IR1IR2IR3IR4IR5IR6IR7IR8IR9IR10IR11\n";