2 key-performer.cc -- implement Key_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 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 void process_music ();
23 void stop_translation_timestep ();
30 Key_performer::Key_performer ()
36 Key_performer::~Key_performer ()
41 Key_performer::process_music ()
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. */
63 SCM third = scm_assoc (scm_from_int (2),
65 bool minor = (scm_is_pair (third)
66 && scm_is_integer (scm_cdr (third))
67 && scm_to_int (scm_cdr (third)) == FLAT);
69 audio_ = new Audio_key (scm_to_int (acc),
72 Audio_element_info info (audio_, key_ev_);
73 announce_element (info);
79 Key_performer::stop_translation_timestep ()
83 play_element (audio_);
89 Key_performer::try_music (Music *ev)
97 #include "translator.icc"
99 ADD_TRANSLATOR (Key_performer,