Re: [frogs] Chord-name-engraver plus capo - pitches |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
Wols Lists wrote Friday, August 27, 2010 12:42 AM
Next glitch - I'm trying to actually do the transpose ... and I
don't
understand this Rational stuff :-(
The code is below:
if (capo) {
Pitch *p = unsmob_pitch (n->get_property ("pitch"));
Pitch orig = p->transposed (Pitch (0, 0, -capo));
capo_pitches = scm_cons ( orig.smobbed_copy (),
capo_pitches);
}
In my code, capo happens to be set to 3 at the moment. In other
words, I
want to transpose down by three semitones. I've already discovered
that
the first argument to Pitch( 0, 0, 0) takes it down three octaves.
The
second takes it down three notenames. So I'm guessing that I need
to
pass something in the third argument. The only problem is, what?
capo is
an int and the above code simply bombs. I've found rational.hh,
but my
C++fu isn't up to understanding what on earth is going on.
So, simply put, how do I describe 3 semitones as a rational, so I
can
get my transposition to work?
Good files to study:
lily/pitch.cc
lily/include/pitch.hh
flower/rational.cc
flower/include/rational.hh
You'll see Pitch::transpose (Pitch delta) is a private
method of the Pitch class, called by Pitch::transposed(d).
Like you, I think this is what you need.
The delta is a pitch, and the alteration is a rational
specified in tones (normally used for sharps and flats)
so I'd guess you'd use
transposedPitch = originalPitch->transposed (Pitch (0, 0, Rational
(-capo/2)));
Caveat: untried and remember I'm also a novice at this.
Trevor
---
----
Join the Frogs!