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
|
|
6212
|
use 5.010000; |
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
4
|
use Moo::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
13
|
1
|
|
|
1
|
|
705
|
use POSIX qw/floor/; |
|
1
|
|
|
|
|
4183
|
|
|
1
|
|
|
|
|
5
|
|
14
|
1
|
|
|
1
|
|
778
|
use Scalar::Util qw/looks_like_number/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
317
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
############################################################################## |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# ATTRIBUTES |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has NOTE2NUM => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
default => sub { |
25
|
|
|
|
|
|
|
{ C => 0, |
26
|
|
|
|
|
|
|
D => 2, |
27
|
|
|
|
|
|
|
E => 4, |
28
|
|
|
|
|
|
|
F => 5, |
29
|
|
|
|
|
|
|
G => 7, |
30
|
|
|
|
|
|
|
A => 9, |
31
|
|
|
|
|
|
|
B => 11, |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has NUM2NOTE => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
default => sub { |
39
|
|
|
|
|
|
|
{ 0 => 'c', |
40
|
|
|
|
|
|
|
1 => 'des', |
41
|
|
|
|
|
|
|
2 => 'd', |
42
|
|
|
|
|
|
|
3 => 'ees', |
43
|
|
|
|
|
|
|
4 => 'e', |
44
|
|
|
|
|
|
|
5 => 'f', |
45
|
|
|
|
|
|
|
6 => 'ges', |
46
|
|
|
|
|
|
|
7 => 'g', |
47
|
|
|
|
|
|
|
8 => 'aes', |
48
|
|
|
|
|
|
|
9 => 'a', |
49
|
|
|
|
|
|
|
10 => 'bes', |
50
|
|
|
|
|
|
|
11 => 'b', |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has ignore_octave => ( |
56
|
|
|
|
|
|
|
is => 'rw', |
57
|
|
|
|
|
|
|
coerce => sub { |
58
|
|
|
|
|
|
|
$_[0] ? 1 : 0; |
59
|
|
|
|
|
|
|
}, |
60
|
|
|
|
|
|
|
default => 0, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
############################################################################## |
64
|
|
|
|
|
|
|
# |
65
|
|
|
|
|
|
|
# METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub pitchname { |
68
|
14
|
|
|
14
|
1
|
53
|
my ( $self, $number ) = @_; |
69
|
14
|
100
|
|
|
|
45
|
die "need a number for pitchname\n" if !looks_like_number $number; |
70
|
|
|
|
|
|
|
|
71
|
13
|
|
|
|
|
36
|
my $note = $self->NUM2NOTE->{ $number % 12 }; |
72
|
|
|
|
|
|
|
|
73
|
13
|
100
|
|
|
|
26
|
if ( !$self->ignore_octave ) { |
74
|
10
|
|
|
|
|
614
|
my $octave = floor( $number / 12 ) - 1; |
75
|
10
|
100
|
|
|
|
19
|
if ( $octave > 3 ) { |
|
|
100
|
|
|
|
|
|
76
|
7
|
|
|
|
|
13
|
$note .= (q{'}) x ( $octave - 3 ); |
77
|
|
|
|
|
|
|
} elsif ( $octave < 3 ) { |
78
|
2
|
|
|
|
|
5
|
$note .= (q{,}) x ( 3 - $octave ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
13
|
|
|
|
|
106
|
return $note; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub pitchnum { |
86
|
16
|
|
|
16
|
1
|
27
|
my ( $self, $name ) = @_; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# already a pitch number, but nix the decimal foo |
89
|
16
|
50
|
|
|
|
46
|
return int $name if looks_like_number $name; |
90
|
|
|
|
|
|
|
|
91
|
16
|
|
|
|
|
13
|
my $pitchnum; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# octave indication only follows accidental, accidental only after note |
94
|
|
|
|
|
|
|
# plus complication for "as", "ases", "es", "eses" special cases |
95
|
16
|
50
|
|
|
|
87
|
if ( |
96
|
|
|
|
|
|
|
$name =~ m/ (? [A-Ga-g] ) |
97
|
|
|
|
|
|
|
(? es(?:es)? | is(?:is)? | (?<=[AEae]) s(?:es)? )? |
98
|
|
|
|
|
|
|
(? [,]{1,10}|[']{1,10} )? |
99
|
|
|
|
|
|
|
/x |
100
|
|
|
|
|
|
|
) { |
101
|
1
|
|
|
1
|
|
377
|
my $octave = $+{octave}; |
|
1
|
|
|
|
|
263
|
|
|
1
|
|
|
|
|
151
|
|
|
16
|
|
|
|
|
81
|
|
102
|
16
|
|
|
|
|
46
|
my $chrome = $+{chrome}; |
103
|
16
|
|
|
|
|
35
|
my $note = $+{note}; |
104
|
|
|
|
|
|
|
|
105
|
16
|
|
|
|
|
42
|
$pitchnum = $self->NOTE2NUM->{ uc $note } + 12 * 4; |
106
|
|
|
|
|
|
|
|
107
|
16
|
100
|
|
|
|
21
|
if ( defined $octave ) { |
108
|
15
|
100
|
|
|
|
40
|
$pitchnum += 12 * length($octave) * ( $octave =~ m/[,]/ ? -1 : 1 ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
16
|
100
|
|
|
|
21
|
if ( defined $chrome ) { |
112
|
12
|
100
|
|
|
|
20
|
if ( $chrome =~ m/^s/ ) { # as/ases klugery |
113
|
4
|
|
|
|
|
5
|
$chrome = "e$chrome"; |
114
|
|
|
|
|
|
|
} |
115
|
12
|
|
|
|
|
14
|
$chrome =~ tr/s//d; |
116
|
12
|
100
|
|
|
|
28
|
$pitchnum += length($chrome) * ( $chrome =~ m/e/ ? -1 : 1 ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
16
|
|
|
|
|
53
|
return $pitchnum; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
__END__ |