| 1 | #! perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 92 | our $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 92 | our $options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package ChordPro::Chords; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 92 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 92 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 92 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 92 | ▶ | use feature qw( signatures ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 92 | ▶ | no warnings "experimental::signatures"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 92 | ▶ | use ChordPro::Chords::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Chords defined by the configs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 92 | my %config_chords; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Names of chords loaded from configs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my @chordnames; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Additional chords, defined by the user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 92 | my %song_chords; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Current tuning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 92 | my @tuning; # names, e.g. E2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 92 | my @t_ord; # ordinals, e.g. 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 92 | my $t_oct; # octave, usually 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Assert that an instrument is loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 215 | ▶ | sub assert_tuning () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_tuning: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 215 | ▶ | Carp::croak("FATAL: No instrument?") unless @tuning; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ################ Section Dumping Chords ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # API: Returns a list of all chord names in a nice order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Used by: ChordPro, Output/ChordPro. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub chordnames () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chordnames: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | [ sort chordcompare @chordnames ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # Chord order ordinals, for sorting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 92 | my %chordorderkey; { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 92 | my $ord = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 92 | for ( split( ' ', "C C# Db D D# Eb E F F# Gb G G# Ab A A# Bb B" ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1564 | $chordorderkey{$_} = $ord; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1564 | $ord += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Compare routine for chord names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # API: Used by: Song. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 7 | ▶ | sub chordcompare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chordcompare: called CC=11 SCAR=37.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 7 | ▶ | ( $a, $b ) = @_ if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | my ( $a0, $arest ) = $a =~ /^([A-G][b#]?)(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | my ( $b0, $brest ) = $b =~ /^([A-G][b#]?)(.*)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 7 | ▶ | $a0 = $chordorderkey{$a0//"\x{ff}"}//return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$chordorderkey{$a0 // "\377"} // (return 0)
$a0 // "\377"
MC/DC0%0/1
$chordorderkey{$a0 // "\377"} // (return 0)
$chordorderkey{$a0 // "\377"}
MC/DC0%0/1
$a0 // "\377"
$a0
Truth table50%1/2
A
A= $chordorderkey{$a0 // "\377"}
Truth table50%1/2
A
A= $a0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 7 | ▶ | $b0 = $chordorderkey{$b0//"\x{ff}"}//return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$chordorderkey{$b0 // "\377"} // (return 0)
$b0 // "\377"
MC/DC0%0/1
$chordorderkey{$b0 // "\377"} // (return 0)
$chordorderkey{$b0 // "\377"}
MC/DC0%0/1
$b0 // "\377"
$b0
Truth table50%1/2
A
A= $chordorderkey{$b0 // "\377"}
Truth table50%1/2
A
A= $b0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | ▶ | return $a0 <=> $b0 if $a0 != $b0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $a0++ if $arest =~ /^m(?:in)?(?!aj)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $b0++ if $brest =~ /^m(?:in)?(?!aj)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | for ( $arest, $brest ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | s/11/:/; # sort 11 after 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | s/13/;/; # sort 13 after 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | s/\((.*?)\)/$1/g; # ignore parens | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | s/\+/aug/; # sort + as aug | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $a0 <=> $b0 || $arest cmp $brest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Dump a textual list of chord definitions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Should be handled by the ChordPro backend? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub list_chords ( $chords, $origin, $hdr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_chords: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $hdr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $t = "-" x (((@tuning - 1) * 4) + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | substr( $t, (length($t)-7)/2, 7, "strings" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | "# CHORD CHART", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | "# Generated by ChordPro " . $ChordPro::VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | "# https://www.chordpro.org", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | "#", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | "# " . ( " " x 35 ) . $t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | "# Chord" . ( " " x 35 ) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | join("", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | map { sprintf("%-4s", $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | @tuning ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | foreach my $chord ( @$chords ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( eval{ $chord->{name} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $info = $chord; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ( $origin eq "chord" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | push( @s, sprintf( "{%s: %s}", "chord", $chord ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $info = known_chord($chord); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | next unless $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | my $s = sprintf( "{%s %-15.15s base-fret %2d ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | "frets %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $origin eq "chord" ? "chord: " : "define:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $info->{name}, $info->{base}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | @{ $info->{frets} // [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{"frets"} // []
MC/DC0%0/1
$info->{"frets"} // []
$info->{"frets"}
Truth table0%0/2
A
A= $info->{"frets"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ? join("", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | map { sprintf("%-4s", $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | map { $_ < 0 ? "X" : $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | @{ $info->{frets} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | : (" " x strings() )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $s .= join("", " fingers ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | map { sprintf("%-4s", $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | map { $_ < 0 ? "X" : $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | @{ $info->{fingers} } ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if $info->{fingers} && @{ $info->{fingers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"fingers"} and @{$info->{"fingers"};}
MC/DC0%0/2
$info->{"fingers"} and @{$info->{"fingers"};}
$info->{"fingers"}
@{$info->{"fingers"};}
Truth table0%0/3
A and B
A= $info->{"fingers"}B= @{$info->{"fingers"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | $s .= join("", " keys ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | map { sprintf("%2d", $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | @{ $info->{keys} } ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if $info->{keys} && @{ $info->{keys} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"keys"} and @{$info->{"keys"};}
MC/DC0%0/2
$info->{"keys"} and @{$info->{"keys"};}
$info->{"keys"}
@{$info->{"keys"};}
Truth table0%0/3
A and B
A= $info->{"keys"}B= @{$info->{"keys"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $s .= "}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | push( @s, $s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | \@s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub dump_chords ( $mode ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_chords: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | print( join( "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $mode && $mode == 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ? @{ json_chords(\@chordnames ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | : @{ list_chords(\@chordnames, "__CLI__", 1) } ), "\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mode and $mode == 2
MC/DC0%0/2
$mode and $mode == 2
$mode
$mode == 2
Truth table0%0/3
A and B
A= $modeB= $mode == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub json_chords ( $chords ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json_chords: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | push( @s, "// ChordPro instrument definition.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | qq<{ "instrument" : "> . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ($::config->{instrument} || "Guitar, 6 strings, standard tuning") . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | qq<",>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | qq< "tuning" : [ > . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | join(", ", map { qq{"$_"} } @tuning) . " ],", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::config->{'instrument'} || 'Guitar, 6 strings, standard tuning'
MC/DC0%0/1
$main::config->{'instrument'} || 'Guitar, 6 strings, standard tuning'
$main::config->{'instrument'}
Truth table0%0/2
A
A= $main::config->{'instrument'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | qq{ "chords" : [}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $maxl = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | foreach my $chord ( @$chords ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $t = length( $chord ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $maxl < $t and $maxl = $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $maxl += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | foreach my $chord ( @$chords ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ( eval{ $chord->{name} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $info = $chord; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $info = known_chord($chord); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | next unless $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $name = '"' . $info->{name} . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | my $s = sprintf( qq[ { "name" : %-${maxl}.${maxl}s,] . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | qq[ "base" : %2d,], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $name, $info->{base} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( @{ $info->{frets} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $s .= qq{ "frets" : [ } . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | join( ", ", map { sprintf("%2s", $_) } @{ $info->{frets} } ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | qq{ ],}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ( $info->{fingers} && @{ $info->{fingers} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"fingers"} and @{$info->{"fingers"};}
MC/DC0%0/2
$info->{"fingers"} and @{$info->{"fingers"};}
$info->{"fingers"}
@{$info->{"fingers"};}
Truth table0%0/3
A and B
A= $info->{"fingers"}B= @{$info->{"fingers"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $s .= qq{ "fingers" : [ } . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | join( ", ", map { sprintf("%2s", $_) } @{ $info->{fingers} } ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | qq{ ],}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $info->{keys} && @{ $info->{keys} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"keys"} and @{$info->{"keys"};}
MC/DC0%0/2
$info->{"keys"} and @{$info->{"keys"};}
$info->{"keys"}
@{$info->{"keys"};}
Truth table0%0/3
A and B
A= $info->{"keys"}B= @{$info->{"keys"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | $s .= qq{ "keys" : [ } . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | join( ", ", map { sprintf("%2d", $_) } @{ $info->{keys} } ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | qq{ ],}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | chop($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $s .= " },"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | push( @s, $s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | chop( $s[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | push( @s, "", " ]," ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $::config->{pdf}->{diagrams}->{vcells} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | push( @s, qq< "pdf" : { "diagrams" : { "vcells" : > . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $::config->{pdf}->{diagrams}->{vcells} . qq< } },> ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | chop( $s[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | push( @s, "}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | \@s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ################ Section Tuning ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # API: Return the number of strings supported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # Used by: Songbook, Output::PDF. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 286521 | ▶ | sub strings () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strings: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 286521 | scalar(@tuning); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 92 | my $parser;# = ChordPro::Chords::Parser->default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # API: Set tuning, discarding chords. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # Used by: Config. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 215 | ▶ | sub set_tuning ( $cfg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_tuning: called CC=11 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 215 | ▶ | my $t = $cfg->{tuning} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"tuning"} // []
MC/DC0%0/1
$cfg->{"tuning"} // []
$cfg->{"tuning"}
Truth table50%1/2
A
A= $cfg->{"tuning"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 215 | ▶ | return "Invalid tuning (not array)" unless ref($t) eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 215 | ▶ | $options //= { verbose => 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$main::options //= {"verbose", 0}
MC/DC0%0/1
$main::options //= {"verbose", 0}
$main::options
Truth table50%1/2
A
A= $main::options
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 215 | ▶ | if ( @tuning ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 123 | ( my $t1 = "@$t" ) =~ s/\d//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 123 | ( my $t2 = "@tuning" ) =~ s/\d//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 123 | ▶ | if ( $t1 ne $t2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | warn("Tuning changed, chords flushed\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if $options->{verbose} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | @chordnames = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | %config_chords = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 92 | @chordnames = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 92 | %config_chords = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 215 | @tuning = @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Get ordinals for tuning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 215 | my $p = ChordPro::Chords::Parser->get_parser("common"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 215 | $t_oct = keys %{ $p->{ns_tbl} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 215 | for ( @tuning ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1290 | ▶ | return "Invalid tuning (should be note + octave): $_" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | unless /(^.*?)(\d+)$/; # split off octave | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1290 | ▶ | my $n = $p->{ns_tbl}->{$1} // $p->{nf_tbl}->{$1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$p->{"ns_tbl"}{$1} // $p->{"nf_tbl"}{$1}
MC/DC0%0/2
$p->{"ns_tbl"}{$1} // $p->{"nf_tbl"}{$1}
$p->{"ns_tbl"}{$1}
$p->{"nf_tbl"}{$1}
Truth table33%1/3
A // B
A= $p->{"ns_tbl"}{$1}B= $p->{"nf_tbl"}{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1290 | ▶ | return "Invalid tuning (unknown note): $1" unless defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1290 | push( @t_ord, $2 * $t_oct + $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 215 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 215 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # API: Get tuning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Used by: String substitution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3053 | ▶ | sub get_tuning () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_tuning: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3053 | @{[@tuning]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # API: Set target parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # Used by: ChordPro. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 7 | ▶ | sub set_parser ( $p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_parser: called CC=4 SCAR=15.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 7 | ▶ | $p = ChordPro::Chords::Parser->get_parser($p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $p and $p->isa("ChordPro::Chords::Parser")
MC/DC0%0/2
ref $p and $p->isa("ChordPro::Chords::Parser")
ref $p
$p->isa("ChordPro::Chords::Parser")
Truth table33%1/3
A and B
A= ref $pB= $p->isa("ChordPro::Chords::Parser")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | unless ref($p) && $p->isa('ChordPro::Chords::Parser'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 7 | $parser = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | warn( "Parser: ", $parser->{system}, "\n" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | ▶ | if $options->{verbose} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Parser stack. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | my @parsers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # API: Reset current parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Used by: Config. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 226 | ▶ | sub reset_parser () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_parser: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 226 | undef $parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 226 | @parsers = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | ▶ | sub get_parser () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parser: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | $parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 215 | ▶ | sub push_parser ( $p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_parser: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 215 | ▶ | $p = ChordPro::Chords::Parser->get_parser($p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $p and $p->isa("ChordPro::Chords::Parser")
MC/DC0%0/2
ref $p and $p->isa("ChordPro::Chords::Parser")
ref $p
$p->isa("ChordPro::Chords::Parser")
Truth table33%1/3
A and B
A= ref $pB= $p->isa("ChordPro::Chords::Parser")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | unless ref($p) && $p->isa('ChordPro::Chords::Parser'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 215 | push( @parsers, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 215 | $parser = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 215 | ▶ | sub pop_parser () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop_parser: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 215 | ▶ | Carp::croak("Parser stack underflow") unless @parsers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 215 | $parser = pop(@parsers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ################ Section Config & User Chords ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2577 | ▶ | sub known_chord ( $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
known_chord: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2577 | my $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2577 | ▶ | if ( ref($name) =~ /^ChordPro::Chord::/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1249 | $info = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1249 | $name = $info->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2577 | ▶ | my $ret = $song_chords{$name} // $config_chords{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$song_chords{$name} // $config_chords{$name}
MC/DC100%2/2
$song_chords{$name} // $config_chords{$name}
$song_chords{$name}
$config_chords{$name}
Truth table100%3/3
A // B
A= $song_chords{$name}B= $config_chords{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2577 | ▶ | $ret->{_via} = $ret->{origin} . " chords", return $ret if $ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 692 | ▶ | return unless $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Retry agnostic. Not all can do that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 345 | $name = eval { $info->agnostic }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 345 | ▶ | return unless $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 327 | ▶ | $ret = $song_chords{$name} // $config_chords{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$song_chords{$name} // $config_chords{$name}
MC/DC50%1/2
$song_chords{$name} // $config_chords{$name}
$song_chords{$name}
$config_chords{$name}
Truth table66%2/3
A // B
A= $song_chords{$name}B= $config_chords{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 327 | ▶ | if ( $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 9 | $ret = $info->new($ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 9 | for ( qw( name display | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | root root_canon root_mod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | qual qual_canon ext ext_canon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | bass bass_canon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | system parser ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 117 | ▶ | next unless defined $info->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 99 | $ret->{$_} = $info->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 9 | $ret->{_via} = "agnostic" . " " . $ret->{origin} . " chords"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 327 | $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 143375 | ▶ | sub check_chord ( $ii ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_chord: called CC=14 SCAR=30.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | my ( $name, $base, $frets, $fingers, $keys ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 143375 | = @$ii{qw(name base frets fingers keys)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 143375 | ▶ | if ( $frets && @$frets && @$frets != strings() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$frets and @$frets and @$frets != strings()
$frets and @$frets
MC/DC0%0/3
$frets and @$frets and @$frets != strings()
$frets
@$frets
@$frets != strings()
Truth table50%2/4
A and B and C
A= $fretsB= @$fretsC= @$frets != strings()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return scalar(@$frets) . " strings"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 143375 | ▶ | if ( $fingers && @$fingers && @$fingers != strings() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$fingers and @$fingers and @$fingers != strings()
$fingers and @$fingers
MC/DC0%0/3
$fingers and @$fingers and @$fingers != strings()
$fingers
@$fingers
@$fingers != strings()
Truth table75%3/4
A and B and C
A= $fingersB= @$fingersC= @$fingers != strings()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return scalar(@$fingers) . " strings for fingers"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 143375 | ▶ | unless ( $base > 0 && $base < 24 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$base > 0 and $base < 24
MC/DC0%0/2
$base > 0 and $base < 24
$base > 0
$base < 24
Truth table33%1/3
A and B
A= $base > 0B= $base < 24
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return "base-fret $base out of range"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 143375 | ▶ | if ( $keys && @$keys ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$keys and @$keys
MC/DC100%2/2
$keys and @$keys
$keys
@$keys
Truth table100%3/3
A and B
A= $keysB= @$keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 12 | for ( @$keys ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 39 | ▶ | return "invalid key \"$_\"" unless /^\d+$/ && $_ < 24; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
/^\d+$/u and $_ < 24
MC/DC0%0/2
/^\d+$/u and $_ < 24
/^\d+$/u
$_ < 24
Truth table33%1/3
A and B
A= /^\d+$/uB= $_ < 24
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 143375 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # API: Access the chords table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # Used by: Utils. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub config_chords { \%config_chords } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_chords: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # API: Add a config defined chord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # Used by: Config. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 143312 | ▶ | sub add_config_chord ( $def ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_config_chord: called CC=36 SCAR=41.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 143312 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | my $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 143312 | my @extprops = qw( display format ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # Handle alternatives. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 143312 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 143312 | ▶ | if ( $def->{name} =~ /.\|./ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $def->{name} = [ split( /\|/, $def->{name} ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 143312 | ▶ | if ( UNIVERSAL::isa( $def->{name}, 'ARRAY' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | $name = shift( @{ $def->{name} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | push( @names, @{ $def->{name} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 143311 | $name = $def->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # For derived chords. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 143312 | ▶ | if ( $def->{copy} || $def->{"copyall"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$def->{"copy"} or $def->{"copyall"}
MC/DC50%1/2
$def->{"copy"} or $def->{"copyall"}
$def->{"copy"}
$def->{"copyall"}
Truth table66%2/3
A or B
A= $def->{"copy"}B= $def->{"copyall"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 60512 | my $src = $def->{copy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 60512 | ▶ | if ( $def->{copyall} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | return "Cannot copy and copyall at the same time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | if $src; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $src = $def->{copyall}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 60512 | $res = $config_chords{$src}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 60512 | ▶ | return "Cannot copy $src" unless $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 60512 | ▶ | if ( $def->{copy} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 60512 | my $r = { %$res }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 60512 | delete $r->{$_} for @extprops; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 60512 | $def = bless { %$r, %$def } => ref($res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $def = bless { %$res, %$def } => ref($res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $def->{copy} = $def->{copyall}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 143312 | delete $def->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 143312 | ▶ | $def->{base} ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$def->{"base"} ||= 1
MC/DC100%1/1
$def->{"base"} ||= 1
$def->{"base"}
Truth table100%2/2
A
A= $def->{"base"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | my ( $base, $frets, $fingers, $keys ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 143312 | ( $def->{base}, $def->{frets}, $def->{fingers}, $def->{keys} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 143312 | $res = check_chord($def); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 143312 | ▶ | return $res if $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 143312 | my $dpinfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 143312 | ▶ | if ( $def->{display} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $dpinfo = parse_chord($def->{display}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ( $dpinfo ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $def->{display} = $dpinfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | delete $def->{display}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 143312 | for $name ( $name, @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 143313 | ▶ | next if $name =~ /^(\||\s*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 143313 | ▶ | my $info = parse_chord($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
parse_chord($name) // "ChordPro::Chord::Common"->new({"name", $name})
MC/DC0%0/2
parse_chord($name) // "ChordPro::Chord::Common"->new({"name", $name})
parse_chord($name)
"ChordPro::Chord::Common"->new({"name", $name})
Truth table66%2/3
A // B
A= parse_chord($name)B= "ChordPro::Chord::Common"->new({"name", $name})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | // ChordPro::Chord::Common->new({ name => $name }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 143313 | ▶ | if ( $info->is_chord && $def->{copy} && $def->is_chord ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$info->is_chord and $def->{"copy"} and $def->is_chord
$info->is_chord and $def->{"copy"}
MC/DC100%3/3
$info->is_chord and $def->{"copy"} and $def->is_chord
$info->is_chord
$def->{"copy"}
$def->is_chord
Truth table100%4/4
A and B and C
A= $info->is_chordB= $def->{"copy"}C= $def->is_chord
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 30876 | for ( qw( root bass ext qual ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 123504 | delete $def->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 123504 | delete $def->{$_."_mod"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 123504 | delete $def->{$_."_canon"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 30876 | for ( qw( ext qual ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 61752 | delete $def->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 61752 | delete $def->{$_."_canon"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 143313 | ▶ | Carp::confess(::dump($parser)) unless $parser->{target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $config_chords{$name} = bless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | { origin => "config", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | system => $parser->{system}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | %$info, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | %$def, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | base => $base, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | baselabeloffset => $def->{baselabeloffset}||0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 859878 | ▶ | frets => [ $frets && @$frets ? map { $_ eq 'x' ? -1 : $_ } @$frets : () ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition83%5/6
$fingers and @$fingers
$keys and @$keys
MC/DC100%2/2
$fingers and @$fingers
$fingers
@$fingers
MC/DC0%0/2
$keys and @$keys
$keys
@$keys
Truth table100%3/3
A and B
A= $fingersB= @$fingers
Truth table66%2/3
A and B
A= $keysB= @$keys
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | fingers => [ $fingers && @$fingers ? @$fingers : () ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | keys => [ $keys && @$keys ? @$keys : () ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 143313 | ▶ | } => $parser->{target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$def->{'baselabeloffset'} || 0
$frets and @$frets
MC/DC0%0/1
$def->{'baselabeloffset'} || 0
$def->{'baselabeloffset'}
MC/DC0%0/2
$frets and @$frets
$frets
@$frets
Truth table50%1/2
A
A= $def->{'baselabeloffset'}
Truth table33%1/3
A and B
A= $fretsB= @$frets
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 143313 | push( @chordnames, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # Also store the chord info under a neutral name so it can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # found when other note name systems are used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 143313 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 143313 | ▶ | if ( $info->is_chord ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 113460 | $i = $info->agnostic; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # Retry with default parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 29853 | $i = ChordPro::Chords::Parser->default->parse($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 29853 | ▶ | if ( $i && $i->is_chord ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$i and $i->is_chord
MC/DC0%0/2
$i and $i->is_chord
$i
$i->is_chord
Truth table33%1/3
A and B
A= $iB= $i->is_chord
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $info->{root_ord} = $i->{root_ord}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $config_chords{$name}->{$_} = $i->{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | for qw( root_ord root_mod ext_canon qual_canon ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $i = $i->agnostic; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 143313 | ▶ | if ( $info->is_chord ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 113460 | $config_chords{$i} = $config_chords{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 113460 | $config_chords{$i}->{origin} = "config"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 143312 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # API: Add a user defined chord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # Used by: Song. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 63 | ▶ | sub add_song_chord ( $ii ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_song_chord: called CC=10 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 63 | ▶ | return if $ii->name =~ /^(\||\s*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 63 | my $res = check_chord($ii); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 63 | ▶ | return $res if $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Need a parser anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 63 | ▶ | $parser //= ChordPro::Chords::Parser->get_parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parser //= "ChordPro::Chords::Parser"->get_parser
MC/DC0%0/2
$parser //= "ChordPro::Chords::Parser"->get_parser
$parser
"ChordPro::Chords::Parser"->get_parser
Truth table33%1/3
A //= B
A= $parserB= "ChordPro::Chords::Parser"->get_parser
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | my $c = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | { system => $parser->{system}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 63 | parser => $parser, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | %$ii, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 63 | ▶ | $c->{origin} //= "user"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->{"origin"} //= "user"
MC/DC0%0/1
$c->{"origin"} //= "user"
$c->{"origin"}
Truth table50%1/2
A
A= $c->{"origin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # Cleanup. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 63 | for ( qw( display ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 63 | ▶ | delete $c->{$_} unless defined $c->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 63 | for ( qw( frets fingers keys ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 189 | ▶ | delete $c->{$_} unless $c->{$_} && @{ $c->{$_} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c->{$_} and @{$c->{$_};}
MC/DC100%2/2
$c->{$_} and @{$c->{$_};}
$c->{$_}
@{$c->{$_};}
Truth table100%3/3
A and B
A= $c->{$_}B= @{$c->{$_};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 63 | $song_chords{$c->{name}} = bless $c => $parser->{target}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 63 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # API: Add an unknown chord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Used by: Song. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | sub add_unknown_chord ( $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_unknown_chord: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | $parser //= ChordPro::Chords::Parser->get_parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parser //= "ChordPro::Chords::Parser"->get_parser
MC/DC0%0/2
$parser //= "ChordPro::Chords::Parser"->get_parser
$parser
"ChordPro::Chords::Parser"->get_parser
Truth table0%0/3
A //= B
A= $parserB= "ChordPro::Chords::Parser"->get_parser
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | $song_chords{$name} = bless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | { origin => "user", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | base => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | frets => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | fingers => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | keys => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | } => $parser->{target}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # API: Reset user defined songs. Should be done for each new song. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # Used by: Songbook, Output::PDF. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 250 | ▶ | sub reset_song_chords () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_song_chords: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 250 | %song_chords = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # API: Return some chord statistics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | sub chord_stats () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chord_stats: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $res = sprintf( "%d config chords", scalar(keys(%config_chords)) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $res .= sprintf( ", %d song chords", scalar(keys(%song_chords)) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | if %song_chords; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ################ Section Chords Parser ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 146782 | ▶ | sub parse_chord ( $chord ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_chord: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 146782 | ▶ | $parser //= ChordPro::Chords::Parser->get_parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parser //= "ChordPro::Chords::Parser"->get_parser
MC/DC0%0/2
$parser //= "ChordPro::Chords::Parser"->get_parser
$parser
"ChordPro::Chords::Parser"->get_parser
Truth table66%2/3
A //= B
A= $parserB= "ChordPro::Chords::Parser"->get_parser
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 146782 | return $parser->parse($chord); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ################ Section Keyboard keys ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 92 | my %keys = | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ( "" => [ 0, 4, 7 ], # major | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | "-" => [ 0, 3, 7 ], # minor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | "7" => [ 0, 4, 7, 10 ], # dominant 7th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | "-7" => [ 0, 3, 7, 10 ], # minor seventh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | "maj7" => [ 0, 4, 7, 11 ], # major 7th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | "-maj7" => [ 0, 3, 7, 11 ], # minor major 7th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | "6" => [ 0, 4, 7, 9 ], # 6th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | "-6" => [ 0, 3, 7, 9 ], # minor 6th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | "6add9" => [ 0, 4, 7, 9, 14], # 6/9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | "5" => [ 0, 7 ], # 6th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | "9" => [ 0, 4, 7, 10, 14 ], # 9th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | "-9" => [ 0, 3, 7, 10, 14 ], # minor 9th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | "maj9" => [ 0, 4, 7, 11, 14 ], # major 9th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | "11" => [ 0, 4, 7, 10, 14, 17 ], # 11th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | "-11" => [ 0, 3, 7, 10, 14, 17 ], # minor 11th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | "13" => [ 0, 4, 7, 10, 14, 17, 21 ], # 13th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | "-13" => [ 0, 3, 7, 10, 14, 17, 21 ], # minor 13th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | "maj13" => [ 0, 4, 7, 11, 14, 21 ], # major 13th | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | "add2" => [ 0, 2, 4, 7 ], # add 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | "add9" => [ 0, 4, 7, 14 ], # add 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | "-add2" => [ 0, 2, 3, 7 ], # minor add 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | "-add9" => [ 0, 2, 3, 7, 11 ], # minor add 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | "-add11" => [ 0, 3, 5, 7, 11 ], # minor add 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | "7-5" => [ 0, 4, 6, 10 ], # 7 flat 5 altered chord | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | "7+5" => [ 0, 4, 8, 10 ], # 7 sharp 5 altered chord | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | "sus4" => [ 0, 5, 7 ], # sus 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | "sus2" => [ 0, 2, 7 ], # sus 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | "7sus2" => [ 0, 2, 7, 10 ], # 7 sus 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | "7sus4" => [ 0, 5, 7, 10 ], # 7 sus 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | "-7sus2" => [ 0, 2, 3, 7, 10 ], # minor 7 sus 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | "-7sus4" => [ 0, 3, 5, 7, 10 ], # minor 7 sus 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | "0" => [ 0, 3, 6 ], # diminished | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | "07" => [ 0, 3, 6, 9 ], # diminished 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | "-7b5" => [ 0, 3, 6, 10 ], # minor 7 flat 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | "+" => [ 0, 4, 8 ], # augmented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | "+7" => [ 0, 4, 8, 10 ], # augmented 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | "h" => [ 0, 3, 6, 10 ], # half-diminished seventh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 547 | ▶ | sub get_keys ( $info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_keys: called CC=19 SCAR=29.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Has keys defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 547 | ▶ | return $info->{keys} if $info->{keys} && @{$info->{keys}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$info->{"keys"} and @{$info->{"keys"};}
MC/DC0%0/2
$info->{"keys"} and @{$info->{"keys"};}
$info->{"keys"}
@{$info->{"keys"};}
Truth table66%2/3
A and B
A= $info->{"keys"}B= @{$info->{"keys"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 547 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 547 | ▶ | if ( defined $info->{qual_canon} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $info->{"qual_canon"} and defined $info->{"ext_canon"} and defined $keys{$info->{"qual_canon"} . $info->{"ext_canon"}}
defined $info->{"qual_canon"} and defined $info->{"ext_canon"}
MC/DC66%2/3
defined $info->{"qual_canon"} and defined $info->{"ext_canon"} and defined $keys{$info->{"qual_canon"} . $info->{"ext_canon"}}
defined $info->{"qual_canon"}
defined $info->{"ext_canon"}
defined $keys{$info->{"qual_canon"} . $info->{"ext_canon"}}
Truth table75%3/4
A and B and C
A= defined $info->{"qual_canon"}B= defined $info->{"ext_canon"}C= defined $keys{$info->{"qual_canon"} . $info->{"ext_canon"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | && defined $info->{ext_canon} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | && defined $keys{$info->{qual_canon}.$info->{ext_canon}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # Known chord extension. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 523 | @keys = @{ $keys{$info->{qual_canon}.$info->{ext_canon}} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # Try to derive from guitar chord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 24 | ▶ | return [] unless $info->{frets} && @{$info->{frets}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$info->{"frets"} and @{$info->{"frets"};}
MC/DC50%1/2
$info->{"frets"} and @{$info->{"frets"};}
$info->{"frets"}
@{$info->{"frets"};}
Truth table66%2/3
A and B
A= $info->{"frets"}B= @{$info->{"frets"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # Get ordinals for tuning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 22 | my @t_ord = map { $_ % $t_oct } @t_ord; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 22 | my %keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 22 | my $i = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 22 | my $base = $info->{base} - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 22 | ▶ | $base = 0 if $base < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 22 | for ( @{ $info->{frets} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 132 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 132 | ▶ | next if $_ < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 48 | my $c = $t_ord[$i] + $_ + $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 48 | ▶ | if ( $info->{root_ord} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 18 | ▶ | $c += $t_oct if $c < $info->{root_ord}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 18 | $c -= $info->{root_ord}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 48 | $keys{ $c % $t_oct }++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 22 | @keys = sort keys %keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 545 | ▶ | if ( defined $info->{bass} && $info->{bass} ne '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $info->{"bass"} and $info->{"bass"} ne ""
MC/DC100%2/2
defined $info->{"bass"} and $info->{"bass"} ne ""
defined $info->{"bass"}
$info->{"bass"} ne ""
Truth table100%3/3
A and B
A= defined $info->{"bass"}B= $info->{"bass"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # Handle inversions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 15 | my @k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 15 | my $bass = $info->{bass_ord} - $info->{root_ord}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 15 | my $oct = 12; # yes | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 15 | ▶ | $bass += $oct if $bass < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 15 | for ( @keys ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 46 | ▶ | next if $_ == $bass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 31 | ▶ | push( @k, $_ < $bass ? $_+$oct : $_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 15 | unshift( @k, $bass ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 15 | @keys = @k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 545 | \@keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ################ Section Transposition ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # API: Transpose a chord. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # Used by: Songbook. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | sub transpose ( $c, $xpose, $xcode = "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transpose: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | return $c unless $xpose || $xcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$xpose or $xcode
MC/DC0%0/2
$xpose or $xcode
$xpose
$xcode
Truth table0%0/3
A or B
A= $xposeB= $xcode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | return $c if $c =~ /^ .+/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $info = parse_chord($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | unless ( $info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | assert_tuning(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | for ( \%song_chords, \%config_chords ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Not sure what this is for... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # Anyway, it causes unknown but {defined} chords to silently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # bypass the trans* warnings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # return if exists($_->{$c}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | $xpose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | ? warn("Cannot transpose $c\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | : warn("Cannot transcode $c\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $res = $info->transcode($xcode)->transpose($xpose)->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # Carp::cluck("__XPOSE = ", $xpose, " __XCODE = $xcode, chord $c => $res\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 92 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||