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 "lily-guile.hh"
11 #include "audio-item.hh"
12 #include "performer.hh"
16 class Key_performer : public Performer
19 TRANSLATOR_DECLARATIONS (Key_performer);
23 virtual bool try_music (Music* req);
24 virtual void create_audio_elements ();
25 virtual void stop_translation_timestep ();
28 Key_change_ev* key_req_;
32 Key_performer::Key_performer ()
38 Key_performer::~Key_performer ()
43 Key_performer::create_audio_elements ()
47 SCM pitchlist = key_req_->get_property ("pitch-alist");
50 proc = scm_primitive_eval (ly_symbol2scm ("alterations-in-key"));
52 SCM acc = gh_call1 (proc, pitchlist);
55 gh_scm2int (ly_caar (pitchlist)),
56 gh_scm2int (ly_cdar (pitchlist)));
61 = ly_transpose_key_alist (pitchlist,
62 interval (key_do, c_do).smobbed_copy ());
64 /* MIDI keys are too limited for lilypond scales.
65 We check for minor scale and assume major otherwise. */
66 SCM minor = scm_primitive_eval (ly_symbol2scm ("minor"));
67 audio_ = new Audio_key (gh_scm2int (acc),
68 SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
70 Audio_element_info info (audio_, key_req_);
71 announce_element (info);
77 Key_performer::stop_translation_timestep ()
81 play_element (audio_);
87 Key_performer::try_music (Music* req)
89 if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (req))
92 warning (_ ("FIXME: key change merge"));
101 ENTER_DESCRIPTION (Key_performer,