Skip to content

Commit

Permalink
Add transpose to Stem.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Jun 3, 2012
1 parent d13c7ad commit 3c1943f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/ABC/Note.pm
@@ -1,8 +1,9 @@
use v6;

use ABC::Duration;
use ABC::Pitched;

class ABC::Note does ABC::Duration {
class ABC::Note does ABC::Duration does ABC::Pitched {
has $.accidental;
has $.basenote;
has $.octave;
Expand Down
7 changes: 6 additions & 1 deletion lib/ABC/Stem.pm
@@ -1,8 +1,9 @@
use v6;

use ABC::Duration;
use ABC::Pitched;

class ABC::Stem does ABC::Duration {
class ABC::Stem does ABC::Duration does ABC::Pitched {
has @.notes;
has $.is-tie;

Expand All @@ -14,4 +15,8 @@ class ABC::Stem does ABC::Duration {
method Str() {
"[" ~ @.notes.join("") ~ "]" ~ ($.is-tie ?? "-" !! "");
}

method transpose($pitch-changer) {
ABC::Stem.new(@.notes>>.transpose($pitch-changer), self, $.is-tie);
}
}
5 changes: 3 additions & 2 deletions t/08-transpose.t
Expand Up @@ -35,9 +35,10 @@ sub up-octave($accidental, $basenote, $octave) {

is transpose("A", &up-octave), "a", "Octave bump to A yields a";
is transpose("a", &up-octave), "a'", "Octave bump to a yields a'";
is transpose("a''", &up-octave), "a'''", "Octave bump to a'' yields a'''";
is transpose("A,", &up-octave), "A", "Octave bump to A, yields A";
is transpose("a''2", &up-octave), "a'''2", "Octave bump to a'' yields a'''";
is transpose("A,-", &up-octave), "A-", "Octave bump to A, yields A";
is transpose("A,,", &up-octave), "A,", "Octave bump to A,, yields A,";
is transpose("[C,Eg]", &up-octave), "[Ceg']", "Octave bump to [C,Eg] yields [Ceg']";


done;

0 comments on commit 3c1943f

Please sign in to comment.