2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
16 Convert evs to audio notes.
18 class Note_performer : public Performer {
20 TRANSLATOR_DECLARATIONS (Note_performer);
23 virtual bool try_music (Music *ev) ;
25 virtual void stop_translation_timestep ();
26 virtual void create_audio_elements ();
29 Link_array<Music> note_evs_;
30 Link_array<Audio_note> notes_;
34 Note_performer::create_audio_elements ()
36 if (note_evs_.size ())
40 SCM prop = get_property ("instrumentTransposition");
41 if (unsmob_pitch (prop))
42 transposing = unsmob_pitch (prop)->semitone_pitch ();
44 while (note_evs_.size ())
46 Music* n = note_evs_.pop ();
47 SCM pit = n->get_property ("pitch");
49 if (Pitch * pitp = unsmob_pitch (pit))
51 Audio_note* p = new Audio_note (*pitp, n->get_length (), - transposing);
52 Audio_element_info info (p, n);
53 announce_element (info);
63 Note_performer::stop_translation_timestep ()
65 // why don't grace notes show up here?
66 // --> grace notes effectively do not get delayed
67 Moment now = now_mom ();
68 for (int i = 0; i < notes_.size (); i++)
70 play_element (notes_[i]);
77 Note_performer::try_music (Music* ev)
79 if (ev->is_mus_type ("note-event"))
84 else if (ev->is_mus_type ("busy-playing-event"))
85 return note_evs_.size ();
90 ADD_TRANSLATOR (Note_performer, "", "",
91 "note-event busy-playing-event", "", "", "");
93 Note_performer::Note_performer ()