blib/lib/Music/ToRoman.pm

filter: Statementstmt 97.0% 165 / 170 Branchbran 86.1% 93 / 108 Conditioncond 90.0% 27 / 30 MC/DCmcdc 83.3% 15 / 18 Subroutinesub 96.9% 32 / 33 Podpod 100% 4 / 4 totaltotal 92.5% 336 / 363 CC 66 SCAR 29.2
CC
66
Cov
93%
parse
40.0
get_scale_chords
12.0
get_scale_degree
9.0
CRAP 18.6
↑ Summary
1 package Music::ToRoman;
2 18 our $AUTHORITY = 'cpan:GENE';
3  
4 # ABSTRACT: Convert notes and chords to Roman numeral notation
5  
6 18 our $VERSION = '0.2002';
7  
8 18 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use List::SomeUtils qw(any first_index);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use Music::Note ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use Music::Scales qw(get_scale_notes);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 has scale_note => (
17 is => 'ro',
18 150 ▶ isa => sub { die 'Invalid note' unless _valid_note( $_[0] ) },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_note($_[0]) 1 149 150
19 3 ▶ default => sub { 'C' },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 18 );
21  
22  
23 has scale_name => (
24 is => 'ro',
25 151 ▶ isa => sub { die 'Invalid scale' unless _valid_scale( $_[0] ) },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_scale($_[0]) 1 150 151
26 20 ▶ default => sub { 'major' },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 18 );
28  
29  
30 has major_tonic => (
31 is => 'ro',
32 152 ▶ isa => sub { die 'Invalid note' unless _valid_note( $_[0] ) },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_note($_[0]) 1 151 152
33 145 ▶ default => sub { 'C' },
Subroutine __ANON__: called CC=1 SCAR=0.0
34 18 );
35  
36  
37 has chords => (
38 is => 'ro',
39 153 ▶ isa => sub { die 'Invalid boolean' unless $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] == 0 or $_[0] == 1 1 152 153
Condition100%3/3
$_[0] == 0 or $_[0] == 1
l!l&&r!l&&!r
130221
MC/DC100%2/2
$_[0] == 0 or $_[0] == 1
$_[0] == 0 $_[0] == 1
Truth table100%3/3
A or B
A= $_[0] == 0B= $_[0] == 1
ABresult
1X1
011
000
40 22 ▶ default => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
41 18 );
42  
43  
44 has verbose => (
45 is => 'ro',
46 149 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 18 );
48  
49  
50 1947 ▶sub parse {
Subroutine parse: called CC=39 SCAR=36.9
Pod documented
51 1947 my ( $self, $chord ) = @_;
52  
53 1947 ▶ die 'No chord to parse'
Branch: 1 branch
BranchTrueFalseTotal
unless $chord 1 1946 1947
54 unless $chord;
55  
56 1946 my $note_re = qr/[A-G][#b]?[#b]?/;
57  
58 # Get the roman representation of the scale
59 1946 my @scale = $self->get_scale_mode;
60 1946 ▶ print "SCALE: @scale\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
61  
62 1946 my @notes;
63  
64 # If the note has a double sharp and is not in major, manually rotate the scale notes, since Music::Scales does not.
65 1946 ▶ if ( $self->scale_note =~ /##/ && $self->scale_name ne 'major' && $self->scale_name ne 'ionian' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->scale_note =~ /##/ and $self->scale_name ne 'major' and $self->scale_name ne 'ionian') { } 42 1904 1946
Condition66%4/6
$self->scale_note =~ /##/ and $self->scale_name ne "major" and $self->scale_name ne "ionian"
!ll&&!rl&&r
1904042
$self->scale_note =~ /##/ and $self->scale_name ne "major"
!ll&&!rl&&r
1904042
MC/DC33%1/3
$self->scale_note =~ /##/ and $self->scale_name ne "major" and $self->scale_name ne "ionian"
$self->scale_note =~ /##/ $self->scale_name ne "major" $self->scale_name ne "ionian"
Truth table50%2/4
A and B and C
A= $self->scale_note =~ /##/B= $self->scale_name ne "major"C= $self->scale_name ne "ionian"
ABCresult
0XX0
10X0
1100
1111
66 42 my %modes = (
67 dorian => 2,
68 phrygian => 3,
69 lydian => 4,
70 mixolydian => 5,
71 aeolian => 6,
72 minor => 6,
73 locrian => 7,
74 );
75  
76 42 @notes = get_scale_notes( $self->major_tonic, 'major' );
77  
78 # Rotate the major scale to the correct mode
79 42 push @notes, shift @notes for 1 .. $modes{ $self->scale_name } - 1;
80 }
81 else {
82 1904 @notes = get_scale_notes( $self->scale_note, $self->scale_name );
83 }
84 1946 ▶ print "NOTES: @notes\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
85  
86 # XXX Not working?
87 # my %ss_enharmonics = (
88 # 'C##' => 'D',
89 # 'D##' => 'E',
90 # 'F##' => 'G',
91 # 'G##' => 'A',
92 # 'A##' => 'B',
93 # );
94 # for ( @notes ) {
95 # $_ = $ss_enharmonics{$_}
96 # if $ss_enharmonics{$_};
97 # }
98 #use Data::Dumper;warn(__PACKAGE__,' ',__LINE__," MARK: ",Dumper\@notes);
99  
100 # Convert a diminished chord
101 1946 $chord =~ s/dim/o/;
102  
103 # Get just the note part of the chord name
104 1946 ( my $note = $chord ) =~ s/^($note_re).*$/$1/;
105  
106 1946 my %bb_enharmonics = (
107 Cbb => 'Bb',
108 Dbb => 'C',
109 Ebb => 'D',
110 Fbb => 'Eb',
111 Gbb => 'F',
112 Abb => 'G',
113 Bbb => 'A',
114 );
115  
116 1946 ▶ $note = $bb_enharmonics{$note}
Branch: 1 branch
BranchTrueFalseTotal
if $note =~ /bb$/ 5 1941 1946
117 if $note =~ /bb$/;
118  
119 # Get the roman representation based on the scale position
120 1946 ▶ my $position = first_index { $_ eq $note } @notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
121  
122 1946 ▶ if ( $position < 0 && ( $note eq 'Cb' || $note eq 'Fb' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($position < 0 and $note eq 'Cb' || $note eq 'Fb') { } 56 1890 1946
elsif ($note eq 'E#') { } 62 1828 1890
Condition100%6/6
$position < 0 and $note eq "Cb" || $note eq "Fb"
!ll&&!rl&&r
150638456
$note eq "Cb" or $note eq "Fb"
l!l&&r!l&&!r
1838384
MC/DC100%3/3
$position < 0 and $note eq "Cb" || $note eq "Fb"
$position < 0 $note eq "Cb" $note eq "Fb"
Truth table100%4/4
A and B or C
A= $position < 0B= $note eq "Cb"C= $note eq "Fb"
ABCresult
0XX0
1000
11X1
1011
123 56 ▶ $note = 'B'
Branch: 1 branch
BranchTrueFalseTotal
if $note eq "Cb" 18 38 56
124 if $note eq 'Cb';
125 56 ▶ $note = 'E'
Branch: 1 branch
BranchTrueFalseTotal
if $note eq "Fb" 38 18 56
126 if $note eq 'Fb';
127 56 ▶ $position = first_index { $_ eq $note } @notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
128 }
129 elsif ( $note eq 'E#' ) { # XXX Why does this work?
130 62 $note = 'F';
131 }
132  
133 1946 my $accidental = '';
134 1946 ▶ if ( $position < 0 && $note =~ /[#b]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($position < 0 and $note =~ /[#b]+$/) 208 1738 1946
Condition100%3/3
$position < 0 and $note =~ /[#b]+$/
!ll&&!rl&&r
1527211208
MC/DC100%2/2
$position < 0 and $note =~ /[#b]+$/
$position < 0 $note =~ /[#b]+$/
Truth table100%3/3
A and B
A= $position < 0B= $note =~ /[#b]+$/
ABresult
0X0
100
111
135 208 my $n = Music::Note->new( $note, 'isobase' );
136 208 my $name = $n->format('isobase');
137 208 ( $accidental = $name ) =~ s/^[A-G]([#b]+)$/$1/;
138 208 ▶ $n->en_eq( $accidental =~ /^#/ ? 'b' : '#' );
Branch: 1 branch
BranchTrueFalseTotal
$accidental =~ /^#/ ? : 93 115 208
139 208 $note = $n->format('isobase');
140 208 ▶ $position = first_index { $_ eq $note } @notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
141 208 $accidental = '';
142 }
143  
144 # If the note is not in the scale find the new position and accidental
145 1946 ▶ if ( $position < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($position < 0) 352 1594 1946
146 352 ( $position, $accidental ) = _pos_acc( $note, $position, \@notes );
147 }
148  
149 1946 my $roman = $scale[$position];
150 1946 ▶ print "ROMAN 1: $roman\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
151  
152 # Get everything but the note part
153 1946 ( my $decorator = $chord ) =~ s/^(?:$note_re)(.*)$/$1/;
154  
155 # Are we minor or diminished?
156 1946 ▶ my $minor = $decorator =~ /[-moø]/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$decorator =~ /[-mo\303\270]/ ? : 268 1678 1946
157 1946 ▶ print "CHORD: $chord, NOTE: $note, NEW ACCI: $accidental, DECO: $decorator, MINOR: $minor, POSN: $position\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
158  
159 # Convert the case of the roman representation based on minor or major
160 1946 ▶ if ( $self->chords ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->chords) 719 1227 1946
161 719 ▶ $roman = $minor && $decorator !~ /maj/i ? lc($roman) : uc($roman);
Branch: 1 branch
BranchTrueFalseTotal
$minor && !($decorator =~ /maj/i) ? : 265 454 719
Condition100%3/3
$minor and not $decorator =~ /maj/i
!ll&&!rl&&r
4513265
MC/DC100%2/2
$minor and not $decorator =~ /maj/i
$minor not $decorator =~ /maj/i
Truth table100%3/3
A and not(B)
A= $minorB= not $decorator =~ /maj/i
ABresult
0X0
100
111
162 }
163  
164 # Add any accidental found in a non-scale note
165 1946 ▶ $roman = $accidental . $roman if $accidental;
Branch: 1 branch
BranchTrueFalseTotal
if $accidental 352 1594 1946
166 1946 ▶ print "ROMAN 2: $roman\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
167  
168 # Handle these unfortunate edge cases:
169 1946 $roman = _up_to_flat( $roman, \@scale );
170 1946 ▶ print "ROMAN 3: $roman\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
171  
172 # Handle the decorator variations
173 1946 ▶ if ( $decorator =~ /maj/i || $decorator =~ /min/i ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($decorator =~ /maj/i or $decorator =~ /min/i) { } 55 1891 1946
elsif ($decorator =~ /\342\226\263/) { } 1 1890 1891
elsif ($decorator =~ /\303\270/) { } 1 1889 1890
Condition100%3/3
$decorator =~ /maj/i or $decorator =~ /min/i
l!l&&r!l&&!r
38171891
MC/DC100%2/2
$decorator =~ /maj/i or $decorator =~ /min/i
$decorator =~ /maj/i $decorator =~ /min/i
Truth table100%3/3
A or B
A= $decorator =~ /maj/iB= $decorator =~ /min/i
ABresult
1X1
011
000
174 55 $decorator = lc $decorator;
175 }
176 elsif ( $decorator =~ /△/ ) {
177 1 $decorator =~ s/△/maj/;
178 }
179 elsif ( $decorator =~ /ø/ ) {
180 1 $decorator =~ s/ø/7b5/;
181 }
182 else {
183 # Drop the minor and major part of the chord name
184 1889 $decorator =~ s/[-Mm]//i;
185 }
186 1946 ▶ print "DECO: $decorator\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
187  
188 # A remaining note name is a bass decorator
189 1946 ▶ if ( $decorator =~ /($note_re)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($decorator =~ /($note_re)/) 207 1739 1946
190 207 my $name = $1;
191  
192 207 ▶ $position = first_index { $_ eq $name } @notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
193 207 ▶ print "BASS NOTE: $name, POSN: $position\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 207 207
194  
195 207 ▶ if ( $position >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($position >= 0) { } 119 88 207
196 119 $decorator =~ s/$note_re/$scale[$position]/;
197 }
198 else {
199 88 ( $position, $accidental ) = _pos_acc( $name, $position, \@notes );
200 88 ▶ print "NEW POSN: $position, ACCI: $accidental\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 88 88
201  
202 88 my $bass = $accidental . $scale[$position];
203 88 $decorator =~ s/$note_re/$bass/;
204  
205 # Handle these unfortunate edge cases
206 88 $decorator = _up_to_flat( $decorator, \@scale );
207 }
208 207 ▶ print "NEW DECO: $decorator\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 207 207
209 }
210  
211 # Append the remaining decorator to the roman representation
212 1946 $roman .= $decorator;
213  
214 1946 $roman =~ s/bI\b/vii/g;
215 1946 $roman =~ s/bIV\b/iii/g;
216  
217 1946 ▶ print "ROMAN 4: $roman\n" if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 1946 1946
218  
219 1946 return $roman;
220 }
221  
222  
223 1946 ▶sub get_scale_mode {
Subroutine get_scale_mode: called CC=8 SCAR=20.8
Pod documented
224 1946 my ($self) = @_;
225  
226 1946 my @scale = qw( I ii iii IV V vi vii ); # Default to major/ionian
227  
228 1946 ▶ if ( $self->scale_name eq 'dorian' ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($self->scale_name eq 'dorian') { } 126 1820 1946
elsif ($self->scale_name eq 'phrygian') { } 126 1694 1820
elsif ($self->scale_name eq 'lydian') { } 126 1568 1694
elsif ($self->scale_name eq 'mixolydian') { } 126 1442 1568
elsif ($self->scale_name eq 'minor' or $self->scale_name eq 'aeolian') { } 128 1314 1442
elsif ($self->scale_name eq 'locrian') { } 126 1188 1314
229 126 @scale = qw( i ii III IV v vi VII );
230 }
231 elsif ( $self->scale_name eq 'phrygian' ) {
232 126 @scale = qw( i II III iv v VI vii );
233 }
234 elsif ( $self->scale_name eq 'lydian' ) {
235 126 @scale = qw( I II iii iv V vi vii );
236 }
237 elsif ( $self->scale_name eq 'mixolydian' ) {
238 126 @scale = qw( I ii iii IV v vi VII );
239 }
240 ▶ elsif ( $self->scale_name eq 'minor' || $self->scale_name eq 'aeolian' ) {
Condition66%2/3
$self->scale_name eq "minor" or $self->scale_name eq "aeolian"
l!l&&r!l&&!r
01281314
MC/DC50%1/2
$self->scale_name eq "minor" or $self->scale_name eq "aeolian"
$self->scale_name eq "minor" $self->scale_name eq "aeolian"
Truth table66%2/3
A or B
A= $self->scale_name eq "minor"B= $self->scale_name eq "aeolian"
ABresult
1X1
011
000
241 128 @scale = qw( i ii III iv v VI VII );
242 }
243 elsif ( $self->scale_name eq 'locrian' ) {
244 126 @scale = qw( i II iii iv V VI vii );
245 }
246  
247 1946 return @scale;
248 }
249  
250  
251 21 ▶sub get_scale_degree {
Subroutine get_scale_degree: called CC=9 SCAR=22.0
Pod documented
252 21 my ($self, $roman) = @_;
253 21 my $degree = 1; # Default to major/ionian
254 21 my $type = 'major';
255 21 ▶ if ( $roman =~ /^vii/i ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($roman =~ /^vii/i) { } 3 18 21
elsif ($roman =~ /^vi/i) { } 3 15 18
elsif ($roman =~ /^v/i) { } 3 12 15
elsif ($roman =~ /^iv/i) { } 3 9 12
elsif ($roman =~ /^iii/i) { } 3 6 9
elsif ($roman =~ /^ii/i) { } 3 3 6
256 3 $degree = 7;
257 }
258 elsif ( $roman =~ /^vi/i ) {
259 3 $degree = 6;
260 }
261 elsif ( $roman =~ /^v/i ) {
262 3 $degree = 5;
263 }
264 elsif ( $roman =~ /^iv/i ) {
265 3 $degree = 4;
266 }
267 elsif ( $roman =~ /^iii/i ) {
268 3 $degree = 3;
269 }
270 elsif ( $roman =~ /^ii/i ) {
271 3 $degree = 2;
272 }
273 21 ▶ if ( $roman =~ /o$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($roman =~ /o$/) { } 7 14 21
elsif ($roman =~ /^[iv]+$/) { } 7 7 14
274 7 $type = 'diminished';
275 }
276 elsif ( $roman =~ /^[iv]+$/ ) {
277 7 $type = 'minor';
278 }
279 21 return $degree, $type;
280 }
281  
282  
283 0 ▶sub get_scale_chords {
Subroutine get_scale_chords: not called CC=3 SCAR=24.8
Pod documented
284 0 my ($self) = @_;
285  
286 0 my %diminished = (
287 major => 'vii',
288 ionian => 'vii',
289 dorian => 'vi',
290 phrygian => 'v',
291 lydian => 'iv',
292 mixolydian => 'iii',
293 minor => 'ii',
294 aeolian => 'ii',
295 locrian => 'i',
296 );
297 0 ▶ my @chords = map { m/^$diminished{ $self->scale_name }$/ ? 'dim' : m/^[A-Z]+$/ ? '' : 'm' } $self->get_scale_mode;
Branch: 2 branches
BranchTrueFalseTotal
/^$diminished{$self->scale_name}$/ ? : 0 0 0
/^[A-Z]+$/ ? : 0 0 0
298  
299 0 return @chords;
300 }
301  
302 2034 ▶sub _up_to_flat {
Subroutine _up_to_flat: called CC=1 SCAR=0.0
303 2034 my ($numeral, $roman) = @_;
304  
305 # Change a roman sharp to a flat of the succeeding scale position
306 2034 ▶ $numeral =~ s/#([IV]+)/b$roman->[ ( ( first_index { lc($1) eq lc($_) } @$roman ) + 1 ) % @$roman ]/i;
Subroutine __ANON__: called CC=1 SCAR=0.0
307  
308 2034 return $numeral;
309 };
310  
311 440 ▶sub _pos_acc {
Subroutine _pos_acc: called CC=6 SCAR=17.9
312 440 my ( $note, $position, $notes ) = @_;
313  
314 440 my $accidental;
315  
316 # If the note has no accidental...
317 440 ▶ if ( length($note) == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $note == 1) { } 265 175 440
318 # Find the scale position of the closest similar note
319 265 ▶ $position = first_index { $_ =~ /^$note/ } @$notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
320  
321 # Get the accidental of the scale note
322 265 ( $accidental = $notes->[$position] ) =~ s/^[A-G](.)$/$1/;
323  
324 # TODO: Explain why.
325 265 ▶ $accidental = $accidental eq '#' ? 'b' : '#';
Branch: 1 branch
BranchTrueFalseTotal
$accidental eq '#' ? : 149 116 265
326 }
327 else {
328 # Enharmonic double sharp equivalents
329 175 my %previous_enharmonics = (
330 'C#' => 'C##',
331 'Db' => 'C##',
332 'F#' => 'F##',
333 'Gb' => 'F##',
334 'G#' => 'G##',
335 'Ab' => 'G##',
336 );
337 $note = $previous_enharmonics{$note}
338 175 ▶ if exists $previous_enharmonics{$note} && any { $_ =~ /[CFG]##/ } @$notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if exists $previous_enharmonics{$note} and &any(sub { $_ =~ /[CFG]##/; } , @$notes) 47 128 175
Condition100%3/3
exists $previous_enharmonics{$note} and &any(sub { $_ =~ /[CFG]##/; } , @$notes)
!ll&&!rl&&r
626647
MC/DC100%2/2
exists $previous_enharmonics{$note} and &any(sub { $_ =~ /[CFG]##/; } , @$notes)
exists $previous_enharmonics{$note} &any(sub { $_ =~ /[CFG]##/; } , @$notes)
Truth table100%3/3
A and B
A= exists $previous_enharmonics{$note}B= &any(sub { $_ =~ /[CFG]##/; } , @$notes)
ABresult
0X0
100
111
339  
340 # Get the accidental of the given note
341 175 ( my $letter, $accidental ) = $note =~ /^([A-G])(.+)$/;
342  
343 # Get the scale position of the closest similar note
344 175 ▶ $position = first_index { $_ =~ /^$letter/ } @$notes;
Subroutine __ANON__: called CC=1 SCAR=0.0
345  
346 175 ▶ $accidental = $accidental eq '##' ? 'b' : $accidental;
Branch: 1 branch
BranchTrueFalseTotal
$accidental eq '##' ? : 47 128 175
347 }
348  
349 440 return $position, $accidental;
350 }
351  
352 302 ▶sub _valid_note {
Subroutine _valid_note: called CC=1 SCAR=0.0
353 302 my ($note) = @_;
354  
355 302 my @valid = ();
356  
357 302 my @notes = 'A' .. 'G';
358  
359 302 push @valid, @notes;
360 302 push @valid, map { $_ . '#' } @notes;
361 302 push @valid, map { $_ . '##' } @notes;
362 302 push @valid, map { $_ . 'b' } @notes;
363  
364 302 ▶ return any { $_ eq $note } @valid;
Subroutine __ANON__: called CC=1 SCAR=0.0
365 }
366  
367 151 ▶sub _valid_scale {
Subroutine _valid_scale: called CC=1 SCAR=0.0
368 151 my ($name) = @_;
369  
370 151 my @valid = qw(
371 ionian
372 major
373 dorian
374 phrygian
375 lydian
376 mixolydian
377 aeolian
378 minor
379 locrian
380 );
381  
382 151 ▶ return any { $_ eq $name } @valid;
Subroutine __ANON__: called CC=1 SCAR=0.0
383 }
384  
385 18 1;
386  
387 __END__
↑ Summary