forked from LastOfTheCarelessMen/ABC
/
Note.pm
32 lines (25 loc) · 927 Bytes
/
Note.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use v6;
use ABC::Duration;
use ABC::Pitched;
class ABC::Note does ABC::Duration does ABC::Pitched {
has $.accidental;
has $.basenote;
has $.octave;
has $.is-tie;
method new($accidental, $basenote, $octave, ABC::Duration $duration, $is-tie) {
self.bless(:$accidental, :$basenote, :$octave, :ticks($duration.ticks), :$is-tie);
}
method pitch() {
$.accidental ~ $.basenote ~ $.octave;
}
method Str() {
$.pitch ~ self.duration-to-str ~ ($.is-tie ?? "-" !! "");
}
method perl() {
"ABC::Note.new({ $.accidental.perl }, { $.basenote.perl }, { $.octave.perl }, { $.ticks.perl }, { $.is-tie.perl })";
}
method transpose($pitch-changer) {
my ($new-accidental, $new-basenote, $new-octave) = $pitch-changer($.accidental, $.basenote, $.octave);
ABC::Note.new($new-accidental, $new-basenote, $new-octave, self, $.is-tie);
}
}