On Fri, May 14, 2010 at 10:20:05PM -0400, D. Michael McIntyre wrote:
> On Friday 14 May 2010, Niek van den Berg wrote:
> > I'm willing to create a patch but I still have another problem. Now at
> > least the notes are correct (B B# A# Cb) but the B# is one octave too high
> > and the Cb is one octave too low. It looks to me
> > Pitch::getOctave(octaveBase) is doing something strange because it ignores
> > the pitch accidental.
Some parts of the Rosegarden code are 'sequencer-like' and work only with the
pitch, ignoring the accidental, like MIDI does. For such code, it would be
mighty confusing if 2 notes with (enharmonically) the same pitch (C and B#)
would be considered to 'be in a different octave'.
I think this justifies the need for the current implementation. On the other
hand, I agree it would be useful to have a way to get the 'accidental-aware'
octave, too.
We could add a new 'getXxxOctave()' which takes into account the accidental, or
rename the current implementation (and references to it) to
'getEnharmonicOctave()' and 'fix' 'getOctave()'. implementation. Someone would
have to come up with better names ;).
The new implementation would be something like:
int
Pitch::newGetOctave(int octaveBase)
{
// the pitch of the note that is left when the accidental is stripped from
// it
int rawNotePitch = m_pitch - getPitchOffset(getAccidental(Key("C major")));
// the octave of the note, disregarding any accidental.
return rawNotePitch / 12 + octaveBase;
}
(untested)
> > But this method is called in several places and I'm
> > not sure what will be broken when changing this. Maybe somebody can
> > comment on this?
>
> I can remember at least one other place in the code where I had to have some
> manual if/then logic in there to override edge cases where Pitch::getOctave()
> would come out wrong. If you make Pitch::getOctave() smarter, you will break
> code in these places, and I don't remember where they are.
We can leave the current code pointing to the current implementation. Those
cases that need the 'accidental-aware' octave can later be cleaned up to use
the new implementation, or be left alone.
Regards,
Arnout
------------------------------------------------------------------------------
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel