Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: colomon/ABC
base: b7a037d069
...
head fork: colomon/ABC
compare: 99fd2669e9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 19, 2012
@colomon 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.
7b573fd
@colomon Make get-Lilypond-pitch not rely on parsing the note twice. 99fd266
View
32 bin/abc2ly.pl
@@ -72,30 +72,18 @@
:$length,
:%cheat-length-map);
}
-
- method get-real-pitch($nominal-pitch) {
- my $match = ABC::Grammar.parse($nominal-pitch, :rule<pitch>);
- if $match<accidental> {
- $nominal-pitch;
- } else {
- ($.key{$match<basenote>.uc} // "") ~ $match<basenote> ~ ($match<octave> // "");
- }
- }
-
- method get-Lilypond-pitch($abc-pitch) {
- # say :$abc-pitch.perl;
- my $real-pitch = self.get-real-pitch($abc-pitch);
- # say :$real-pitch.perl;
- my $match = ABC::Grammar.parse($real-pitch, :rule<pitch>);
+
+ method get-Lilypond-pitch(ABC::Note $abc-pitch) {
+ my $real-accidental = $abc-pitch.accidental || ($.key{$abc-pitch.basenote.uc} // "");
- my $octave = +((~$match<basenote>) ~~ 'a'..'z');
- given $match<octave> {
+ my $octave = +($abc-pitch.basenote ~~ 'a'..'z');
+ given $abc-pitch.octave {
when !*.defined { } # skip if no additional octave info
- when /\,/ { $octave -= (~$match<octave>).chars }
- when /\'/ { $octave += (~$match<octave>).chars }
+ when /\,/ { $octave -= $abc-pitch.octave.chars }
+ when /\'/ { $octave += $abc-pitch.octave.chars }
}
- $match<basenote>.lc ~ %accidental-map{~($match<accidental> // "")} ~ %octave-map{$octave};
+ $abc-pitch.basenote.lc ~ %accidental-map{$real-accidental} ~ %octave-map{$octave};
}
method get-Lilypond-duration(ABC::Duration $abc-duration) {
@@ -177,11 +165,11 @@ (ABC::Header $header, $out)
method StemPitchToLilypond($stem) {
given $stem {
when ABC::Note {
- $.context.get-Lilypond-pitch($stem.pitch)
+ $.context.get-Lilypond-pitch($stem)
}
when ABC::Stem {
- "<" ~ $stem.notes.map({ $.context.get-Lilypond-pitch($_.pitch) }).join(' ') ~ ">"
+ "<" ~ $stem.notes.map({ $.context.get-Lilypond-pitch($_) }).join(' ') ~ ">"
}
die "Unrecognized alleged stem: " ~ $stem.perl;
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() {

No commit comments for this range

Something went wrong with that request. Please try again.