2 key-performer.cc -- implement Key_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "music-sequence.hh"
10 #include "audio-item.hh"
11 #include "performer.hh"
14 class Key_performer : public Performer
17 TRANSLATOR_DECLARATIONS (Key_performer);
21 virtual bool try_music (Music* ev);
22 virtual void create_audio_elements ();
23 virtual void stop_translation_timestep ();
30 Key_performer::Key_performer ()
36 Key_performer::~Key_performer ()
41 Key_performer::create_audio_elements ()
45 SCM pitchlist = key_ev_->get_property ("pitch-alist");
46 SCM proc = ly_lily_module_constant ("alterations-in-key");
48 SCM acc = scm_call_1 (proc, pitchlist);
51 scm_to_int (scm_caar (pitchlist)),
52 scm_to_int (scm_cdar (pitchlist)));
57 = ly_transpose_key_alist (pitchlist,
58 pitch_interval (key_do, c_do).smobbed_copy ());
60 /* MIDI keys are too limited for lilypond scales.
61 We check for minor scale and assume major otherwise. */
62 SCM minor = scm_c_eval_string ("minor");
63 audio_ = new Audio_key (scm_to_int (acc),
64 SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
66 Audio_element_info info (audio_, key_ev_);
67 announce_element (info);
73 Key_performer::stop_translation_timestep ()
77 play_element (audio_);
83 Key_performer::try_music (Music* ev)
85 if (Event *kc = dynamic_cast <Event *> (ev))
88 warning (_ ("FIXME: key change merge"));
97 ADD_TRANSLATOR (Key_performer,