Subject: | Note-name enhancement for Guitar::Scale |
Hello!
I found the need to see the actual notes in a scale on the guitar fretboard. Your module is great by showing symbolic and binary representations! So I added a section to the pv() function, just under # print scale, to figure out the note names and lay them out linearly, as with your other representation. Here is the code... I hope you will accept it an integrate it into your module. :-)
...
$str .= substr($col, 5, 25). "\n";
$str .= substr($col, 0, 25). "\n";
# List note names if requested
my %note_values = (
1 => [qw/E F Fs|Gb G Gs|Ab A As|Bb B C Cs|Db D Ds|Eb/],
2 => [qw/B C Cs|Db D Ds|Eb E F Fs|Gb G Gs|Ab A As|Bb/],
3 => [qw/G Gs|Ab A As|Bb B C Cs|Db D Ds|Eb E F Fs|Gb/],
4 => [qw/D Ds|Eb E F Fs|Gb G Gs|Ab A As|Bb B C Cs|Db/],
5 => [qw/A As|Bb B C Cs|Db D Ds|Eb E F Fs|Gb G Gs|Ab/],
6 => [qw/E F Fs|Gb G Gs|Ab A As|Bb B C Cs|Db D Ds|Eb/],
);
my %notes;
my $i = 0;
while ($str =~ /^(\d+)$/mg) {
my $j = 0;
for my $bit ( split //, $1 ) {
my $value = $note_values{$i + 1}[$j % 12];
my @enharmonics = split /\|/, $value;
if ( @enharmonics > 1 ) {
$value = $_key =~ /#/ ? $enharmonics[0] : $enharmonics[1];
$value =~ s/s/#/;
}
push @{ $notes{$i + 1} }, $bit ? $value : '-';
$j++;
}
$i++;
}
my $notes;
for my $n ( sort keys %notes ) {
$notes .= join( ' ', map { sprintf '%-2s', $_ } @{ $notes{$n} } ) . "\n";
}
$mode || do {
$str =~ s/0/--+/g;
...