2 note-performer.cc -- implement Drum_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"
15 class Drum_note_performer : public Performer
18 TRANSLATOR_DECLARATIONS (Drum_note_performer);
21 virtual bool try_music (Music *ev);
22 virtual void stop_translation_timestep ();
23 virtual void create_audio_elements ();
26 Link_array<Music> note_evs_;
27 Link_array<Audio_note> notes_;
31 Drum_note_performer::create_audio_elements ()
34 if (!tab) tab = get_property ("drumPitchTable");
36 while (note_evs_.size ())
38 Music *n = note_evs_.pop ();
39 SCM sym = n->get_property ("drum-type");
42 if (scm_is_symbol (sym)
43 && (scm_hash_table_p (tab) == SCM_BOOL_T))
44 defn = scm_hashq_ref (tab, sym, SCM_EOL);
46 if (Pitch *pit = unsmob_pitch (defn))
48 Audio_note *p = new Audio_note (*pit, n->get_length (), 0);
49 Audio_element_info info (p, n);
50 announce_element (info);
59 Drum_note_performer::stop_translation_timestep ()
61 // why don't grace notes show up here?
62 // --> grace notes effectively do not get delayed
63 Moment now = now_mom ();
64 for (int i = 0; i < notes_.size (); i++)
66 play_element (notes_[i]);
73 Drum_note_performer::try_music (Music *ev)
75 if (ev->is_mus_type ("note-event"))
80 else if (ev->is_mus_type ("busy-playing-event"))
81 return note_evs_.size ();
86 ADD_TRANSLATOR (Drum_note_performer,
87 "Play drum notes.", "",
88 "note-event busy-playing-event", "", "", "");
90 Drum_note_performer::Drum_note_performer ()