source file of the GNU LilyPond music typesetter
- (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "event.hh"
void
Event::transpose (Pitch delta)
{
+ /*
+ TODO: should change music representation such that
+ _all_ pitch values are transposed automatically.
+ */
+
Pitch *p = unsmob_pitch (get_mus_property ("pitch"));
if (!p)
return ;
- Pitch np = *p;
- np.transpose (delta);
+ Pitch np = p->transposed (delta);
- if (abs (np.alteration_) > 2)
+ if (abs (np.get_alteration ()) > 2)
{
- warning (_f ("Transposition by %s makes accidental larger than two",
- delta.string ()));
+ warning (_f ("Transposition by %s makes alteration larger than two",
+ delta.to_string ()));
}
set_mus_property ("pitch", np.smobbed_copy ());
}
Pitch
- Event::to_relative_octave (Pitch last)
+Event::to_relative_octave (Pitch last)
{
Pitch *old_pit = unsmob_pitch (get_mus_property ("pitch"));
if (old_pit)
{
Pitch new_pit = *old_pit;
- new_pit.to_relative_octave (last);
+ new_pit = new_pit.to_relative_octave (last);
set_mus_property ("pitch", new_pit.smobbed_copy ());
return new_pit;
/*
This is hairy, since the scale in a key-change event may contain
octaveless notes.
+
+
+ TODO: this should use ly:pitch.
*/
LY_DEFINE(transpose_key_alist, "ly:transpose-key-alist",
2, 0,0, (SCM l, SCM pitch),
if (gh_pair_p (key))
{
Pitch orig (gh_scm2int (ly_car (key)),
- gh_scm2int (ly_cdr (key)),
- gh_scm2int (alter));
+ gh_scm2int (ly_cdr (key)),
+ gh_scm2int (alter));
- orig.transpose (*p);
+ orig =orig.transposed (*p);
SCM key = gh_cons (scm_int2num (orig.get_octave ()),
- scm_int2num (orig.notename_));
+ scm_int2num (orig.get_notename ()));
- newlist = gh_cons (gh_cons (key, scm_int2num (orig.alteration_)),
+ newlist = gh_cons (gh_cons (key, scm_int2num (orig.get_alteration ())),
newlist);
}
else if (gh_number_p (key))
{
Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
- orig.transpose (*p);
+ orig = orig.transposed (*p);
- key =scm_int2num (orig.notename_);
- alter = scm_int2num (orig.alteration_);
+ key =scm_int2num (orig.get_notename ());
+ alter = scm_int2num (orig.get_alteration());
newlist = gh_cons (gh_cons (key, alter), newlist);
}
}
}
void
-Key_change_req::transpose (Pitch p)
+Key_change_ev::transpose (Pitch p)
{
SCM pa = get_mus_property ("pitch-alist");
set_mus_property ("pitch-alist", transpose_key_alist (pa, p.smobbed_copy()));
+ Pitch tonic = *unsmob_pitch (get_mus_property ("tonic"));
+ set_mus_property ("tonic",
+ tonic.smobbed_copy ());
}
-
bool
alist_equal_p (SCM a, SCM b)
{
}
return true;
}
-
-bool
-Key_change_req::do_equal_b (Event const * m )const
-{
- Key_change_req const * kc =dynamic_cast<Key_change_req const*> (m);
-
- if(!kc)
- return false;
- return alist_equal_p (get_mus_property ("pitch-alist"),
- kc->get_mus_property ("pitch-alist"));
-}
-
-ADD_MUSIC (Key_change_req);
+ADD_MUSIC (Key_change_ev);