2 key-performer.cc -- implement Key_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "audio-item.hh"
10 #include "performer.hh"
13 class Key_performer : public Performer
16 TRANSLATOR_DECLARATIONS (Key_performer);
20 virtual bool try_music (Music* req);
21 virtual void create_audio_elements ();
22 virtual void stop_translation_timestep ();
25 Key_change_ev* key_req_;
29 Key_performer::Key_performer ()
35 Key_performer::~Key_performer ()
40 Key_performer::create_audio_elements ()
44 SCM pitchlist = key_req_->get_property ("pitch-alist");
45 SCM proc = ly_scheme_function ("alterations-in-key");
47 SCM acc = scm_call_1 (proc, pitchlist);
50 scm_to_int (scm_caar (pitchlist)),
51 scm_to_int (scm_cdar (pitchlist)));
56 = ly_transpose_key_alist (pitchlist,
57 pitch_interval (key_do, c_do).smobbed_copy ());
59 /* MIDI keys are too limited for lilypond scales.
60 We check for minor scale and assume major otherwise. */
61 SCM minor = scm_c_eval_string ("minor");
62 audio_ = new Audio_key (scm_to_int (acc),
63 SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
65 Audio_element_info info (audio_, key_req_);
66 announce_element (info);
72 Key_performer::stop_translation_timestep ()
76 play_element (audio_);
82 Key_performer::try_music (Music* req)
84 if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (req))
87 warning (_ ("FIXME: key change merge"));
96 ADD_TRANSLATOR (Key_performer,