line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# For BACH. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Run perldoc(1) on this file for additional documentation. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Music::PitchNum::German; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8690
|
use 5.010000; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
75
|
|
10
|
2
|
|
|
2
|
|
10
|
use Moo::Role; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
11
|
2
|
|
|
2
|
|
1208
|
use POSIX qw/floor/; |
|
2
|
|
|
|
|
5646
|
|
|
2
|
|
|
|
|
13
|
|
12
|
2
|
|
|
2
|
|
1067
|
use Scalar::Util qw/looks_like_number/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
686
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# for pitchnum (TODO make these attributes or otherwise f(x) calls?) |
17
|
|
|
|
|
|
|
my %NOTE2NUM = ( |
18
|
|
|
|
|
|
|
C => 0, |
19
|
|
|
|
|
|
|
D => 2, |
20
|
|
|
|
|
|
|
E => 4, |
21
|
|
|
|
|
|
|
F => 5, |
22
|
|
|
|
|
|
|
G => 7, |
23
|
|
|
|
|
|
|
A => 9, |
24
|
|
|
|
|
|
|
B => 10, |
25
|
|
|
|
|
|
|
H => 11, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
# NOTE lilypond picky about "ees" and "aes" in deutsch mode |
28
|
|
|
|
|
|
|
my %NUM2NOTE = ( |
29
|
|
|
|
|
|
|
0 => 'c', |
30
|
|
|
|
|
|
|
1 => 'des', |
31
|
|
|
|
|
|
|
2 => 'd', |
32
|
|
|
|
|
|
|
3 => 'es', |
33
|
|
|
|
|
|
|
4 => 'e', |
34
|
|
|
|
|
|
|
5 => 'f', |
35
|
|
|
|
|
|
|
6 => 'ges', |
36
|
|
|
|
|
|
|
7 => 'g', |
37
|
|
|
|
|
|
|
8 => 'as', |
38
|
|
|
|
|
|
|
9 => 'a', |
39
|
|
|
|
|
|
|
10 => 'b', |
40
|
|
|
|
|
|
|
11 => 'h', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
############################################################################## |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub pitchname { |
48
|
11
|
|
|
11
|
1
|
12035
|
my ( $self, $number ) = @_; |
49
|
11
|
100
|
|
|
|
48
|
die "need a number for pitchname\n" if !looks_like_number $number; |
50
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
39
|
my $octave = floor( $number / 12 ) - 1; |
52
|
10
|
|
|
|
|
21
|
my $note = $NUM2NOTE{ $number % 12 }; |
53
|
|
|
|
|
|
|
|
54
|
10
|
100
|
|
|
|
25
|
$note .= (q{'}) x ( $octave - 3 ) if $octave > 3; |
55
|
10
|
100
|
|
|
|
23
|
$note .= (q{,}) x ( 3 - $octave ) if $octave < 3; |
56
|
|
|
|
|
|
|
|
57
|
10
|
|
|
|
|
36
|
return $note; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub pitchnum { |
61
|
12
|
|
|
12
|
1
|
21
|
my ( $self, $name ) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# already a pitch number, but nix the decimal foo |
64
|
12
|
50
|
|
|
|
45
|
return int $name if looks_like_number $name; |
65
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
10
|
my $pitchnum; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# octave indication only follows accidental, accidental only after note |
69
|
12
|
50
|
|
|
|
70
|
if ( $name =~ |
70
|
|
|
|
|
|
|
m/ (? [A-Ha-h] ) (? es(?:es)? | is(?:is)? )? (? [,]{1,10}|[']{1,10} )? /x |
71
|
|
|
|
|
|
|
) { |
72
|
12
|
|
|
1
|
|
72
|
my $octave = $+{octave}; |
|
1
|
|
|
|
|
610
|
|
|
1
|
|
|
|
|
408
|
|
|
1
|
|
|
|
|
156
|
|
73
|
12
|
|
|
|
|
38
|
my $chrome = $+{chrome}; |
74
|
12
|
|
|
|
|
33
|
my $note = $+{note}; |
75
|
|
|
|
|
|
|
|
76
|
12
|
|
|
|
|
26
|
$pitchnum = $NOTE2NUM{ uc $note } + 12 * 4; |
77
|
|
|
|
|
|
|
|
78
|
12
|
100
|
|
|
|
22
|
if ( defined $octave ) { |
79
|
11
|
100
|
|
|
|
44
|
$pitchnum += 12 * length($octave) * ( $octave =~ m/[,]/ ? -1 : 1 ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
12
|
100
|
|
|
|
22
|
if ( defined $chrome ) { |
83
|
4
|
|
|
|
|
6
|
$chrome =~ tr/s//d; |
84
|
4
|
100
|
|
|
|
12
|
$pitchnum += length($chrome) * ( $chrome =~ m/e/ ? -1 : 1 ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
12
|
|
|
|
|
45
|
return $pitchnum; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |