line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Pitch name conversion compatible with Lilypond default or "\language |
4
|
|
|
|
|
|
|
# nederlands" (the default!) is set. See instead German.pm of this |
5
|
|
|
|
|
|
|
# distribution if you instead need "\language deutsch" support. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Run perldoc(1) on this file for additional documentation. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Music::PitchNum::Dutch; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
7670
|
use 5.010000; |
|
1
|
|
|
|
|
2
|
|
12
|
1
|
|
|
1
|
|
3
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
|
1
|
|
837
|
use POSIX qw/floor/; |
|
1
|
|
|
|
|
5180
|
|
|
1
|
|
|
|
|
4
|
|
14
|
1
|
|
|
1
|
|
968
|
use Scalar::Util qw/looks_like_number/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
325
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %NOTE2NUM = ( |
19
|
|
|
|
|
|
|
C => 0, |
20
|
|
|
|
|
|
|
D => 2, |
21
|
|
|
|
|
|
|
E => 4, |
22
|
|
|
|
|
|
|
F => 5, |
23
|
|
|
|
|
|
|
G => 7, |
24
|
|
|
|
|
|
|
A => 9, |
25
|
|
|
|
|
|
|
B => 11, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my %NUM2NOTE = ( |
29
|
|
|
|
|
|
|
0 => 'c', |
30
|
|
|
|
|
|
|
1 => 'des', |
31
|
|
|
|
|
|
|
2 => 'd', |
32
|
|
|
|
|
|
|
3 => 'ees', |
33
|
|
|
|
|
|
|
4 => 'e', |
34
|
|
|
|
|
|
|
5 => 'f', |
35
|
|
|
|
|
|
|
6 => 'ges', |
36
|
|
|
|
|
|
|
7 => 'g', |
37
|
|
|
|
|
|
|
8 => 'aes', |
38
|
|
|
|
|
|
|
9 => 'a', |
39
|
|
|
|
|
|
|
10 => 'bes', |
40
|
|
|
|
|
|
|
11 => 'b', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
############################################################################## |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub pitchname { |
48
|
14
|
|
|
14
|
1
|
11177
|
my ( $self, $number, %params ) = @_; |
49
|
14
|
100
|
|
|
|
57
|
die "need a number for pitchname\n" if !looks_like_number $number; |
50
|
|
|
|
|
|
|
|
51
|
13
|
|
100
|
|
|
43
|
$params{ignore_octave} //= 0; |
52
|
|
|
|
|
|
|
|
53
|
13
|
|
|
|
|
27
|
my $note = $NUM2NOTE{ $number % 12 }; |
54
|
|
|
|
|
|
|
|
55
|
13
|
100
|
|
|
|
24
|
if ( !$params{ignore_octave} ) { |
56
|
10
|
|
|
|
|
42
|
my $octave = floor( $number / 12 ) - 1; |
57
|
10
|
100
|
|
|
|
24
|
if ( $octave > 3 ) { |
|
|
100
|
|
|
|
|
|
58
|
7
|
|
|
|
|
15
|
$note .= (q{'}) x ( $octave - 3 ); |
59
|
|
|
|
|
|
|
} elsif ( $octave < 3 ) { |
60
|
2
|
|
|
|
|
4
|
$note .= (q{,}) x ( 3 - $octave ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
13
|
|
|
|
|
46
|
return $note; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub pitchnum { |
68
|
16
|
|
|
16
|
1
|
26
|
my ( $self, $name ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# already a pitch number, but nix the decimal foo |
71
|
16
|
50
|
|
|
|
57
|
return int $name if looks_like_number $name; |
72
|
|
|
|
|
|
|
|
73
|
16
|
|
|
|
|
12
|
my $pitchnum; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# octave indication only follows accidental, accidental only after note |
76
|
|
|
|
|
|
|
# plus complication for "as", "ases", "es", "eses" special cases |
77
|
16
|
50
|
|
|
|
106
|
if ( |
78
|
|
|
|
|
|
|
$name =~ m/ (? [A-Ga-g] ) |
79
|
|
|
|
|
|
|
(? es(?:es)? | is(?:is)? | (?<=[AEae]) s(?:es)? )? |
80
|
|
|
|
|
|
|
(? [,]{1,10}|[']{1,10} )? |
81
|
|
|
|
|
|
|
/x |
82
|
|
|
|
|
|
|
) { |
83
|
1
|
|
|
1
|
|
463
|
my $octave = $+{octave}; |
|
1
|
|
|
|
|
315
|
|
|
1
|
|
|
|
|
182
|
|
|
16
|
|
|
|
|
91
|
|
84
|
16
|
|
|
|
|
49
|
my $chrome = $+{chrome}; |
85
|
16
|
|
|
|
|
42
|
my $note = $+{note}; |
86
|
|
|
|
|
|
|
|
87
|
16
|
|
|
|
|
35
|
$pitchnum = $NOTE2NUM{ uc $note } + 12 * 4; |
88
|
|
|
|
|
|
|
|
89
|
16
|
100
|
|
|
|
26
|
if ( defined $octave ) { |
90
|
15
|
100
|
|
|
|
41
|
$pitchnum += 12 * length($octave) * ( $octave =~ m/[,]/ ? -1 : 1 ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
16
|
100
|
|
|
|
30
|
if ( defined $chrome ) { |
94
|
12
|
100
|
|
|
|
21
|
if ( $chrome =~ m/^s/ ) { # as/ases klugery |
95
|
4
|
|
|
|
|
8
|
$chrome = "e$chrome"; |
96
|
|
|
|
|
|
|
} |
97
|
12
|
|
|
|
|
19
|
$chrome =~ tr/s//d; |
98
|
12
|
100
|
|
|
|
30
|
$pitchnum += length($chrome) * ( $chrome =~ m/e/ ? -1 : 1 ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
16
|
|
|
|
|
51
|
return $pitchnum; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
__END__ |