2 key-performer.cc -- implement Key_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 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 ()
51 SCM pitchlist = key_req_->get_mus_property ("pitch-alist");
52 SCM proc = scm_primitive_eval (ly_symbol2scm ("accidentals-in-key"));
53 SCM acc = gh_call1 (proc, pitchlist);
54 proc = scm_primitive_eval (ly_symbol2scm ("major-key"));
57 gh_scm2int (ly_caar (pitchlist)),
58 gh_scm2int (ly_cdar (pitchlist)));
61 (7 - gh_scm2int (ly_caar (pitchlist))) % 7,
62 -gh_scm2int (ly_cdar (pitchlist)));
64 my_do = my_do.transposed (to_c);
65 to_c = my_do.transposed (Pitch(0,0,- my_do.get_alteration ()));
67 SCM c_pitchlist = transpose_key_alist (pitchlist, to_c.smobbed_copy());
68 SCM major = gh_call1 (proc, c_pitchlist);
70 audio_ = new Audio_key (gh_scm2int (acc), major == SCM_BOOL_T);
71 Audio_element_info info (audio_, key_req_);
72 announce_element (info);
78 Key_performer::stop_translation_timestep ()
82 play_element (audio_);
88 Key_performer::try_music (Music* req)
90 if (Key_change_ev *kc = dynamic_cast <Key_change_ev *> (req))
93 warning (_ ("FIXME: key change merge"));
102 ENTER_DESCRIPTION(Key_performer,