Ok, I blew the 7ths. Eh.
use strict;
sub build_scale
{
# The parameter is the key of the scale
# as in "what key is a bicycle in? B flat"
my $key = shift;
my @notes = ('C', 'C#/Db', 'D', 'D#/Eb', 'E', 'F', 'F#/Gb',
'G', 'G#/Ab', 'A', 'A#/Bb', 'B');
my @intervals = (0, 2, 4, 5, 7, 9, 11, 12);
# Create a scale based on the intervals in a major scale
my @scale = map {$notes[($key + $intervals[$_]) % 12]} (0..7);
return @scale;
}
sub blues_in
{
my $key = shift;
my @scale = build_scale($key);
#my @blues = qw( 1 1 1 1 4 4 1 1 5 4 1 1);
my @blues = qw( 0 0 0 0 3 3 0 0 4 4 0 0);
print "Blues in $scale[0]:",
join (" ", map {$scale[$_]} @blues),"\n";
}
sub chord_progression
{
my @scale = build_scale( shift);
# Create triads. Increment each note within the scale.
# All notes in the chord progression fall within the
# major scale.
my ($root, $third, $fifth) = (0, 2, 4);
my @name = ('Maj', 'min', 'min', 'Maj', 'Maj', 'min', 'Dim', 'Maj'
+);
for (0..7) {
printf "%6s %3s: %6s, %6s, %6s\n",
$scale[$root], $name[$_], $scale[$root],
$scale[$third], $scale[$fifth];
$root++;
$third++;
$fifth++;
$root %= 7;
$third %= 7;
$fifth %= 7;
}
print "\n";
}
# Call the subroutine for each note in the scale
for (0..11)
{
# chord_progression($_);
blues_in($_);
}