Browse files

ABC::Note now splits pitch into accidental, basenote, and octave. We …

…don't take advantage of it yet, but it's a significant step to making big improvements.
  • Loading branch information...
1 parent b7a037d commit 7b573fd6a99abf743f72140264dffc1120e4a58c @colomon committed May 19, 2012
Showing with 22 additions and 6 deletions.
  1. +6 −2 lib/ABC/Actions.pm
  2. +7 −1 lib/ABC/BrokenRhythm.pm
  3. +9 −3 lib/ABC/Note.pm
View
8 lib/ABC/Actions.pm
@@ -41,7 +41,9 @@ class ABC::Actions {
}
method mnote($/) {
- make ABC::Note.new(~$<pitch>,
+ make ABC::Note.new(~($<pitch><accidental> // ""),
+ ~$<pitch><basenote>,
+ ~($<pitch><octave> // ""),
$<note_length>.ast,
?$<tie>);
}
@@ -75,7 +77,9 @@ class ABC::Actions {
}
method grace_note($/) {
- make ABC::Note.new(~$<pitch>,
+ make ABC::Note.new(~($<pitch><accidental> // ""),
+ ~$<pitch><basenote>,
+ ~($<pitch><octave> // ""),
$<note_length>.ast,
False);
}
View
8 lib/ABC/BrokenRhythm.pm
@@ -26,7 +26,13 @@ class ABC::BrokenRhythm does ABC::Duration {
sub new-rhythm($note, $ticks) {
given $note {
- when ABC::Note { ABC::Note.new($note.pitch, ABC::Duration.new(:$ticks), $note.is-tie); }
+ when ABC::Note {
+ ABC::Note.new($note.accidental,
+ $note.basenote,
+ $note.octave,
+ ABC::Duration.new(:$ticks),
+ $note.is-tie);
+ }
when ABC::Stem { ABC::Stem.new($note.notes.map({ new-rhythm($_, $ticks); })); }
}
}
View
12 lib/ABC/Note.pm
@@ -3,11 +3,17 @@ use v6;
use ABC::Duration;
class ABC::Note does ABC::Duration {
- has $.pitch;
+ has $.accidental;
+ has $.basenote;
+ has $.octave;
has $.is-tie;
- method new($pitch, ABC::Duration $duration, $is-tie) {
- self.bless(*, :$pitch, :ticks($duration.ticks), :$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() {

0 comments on commit 7b573fd

Please sign in to comment.