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"
17 class Drum_note_performer : public Performer
20 TRANSLATOR_DECLARATIONS (Drum_note_performer);
23 virtual bool try_music (Music *ev);
24 PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
25 virtual void create_audio_elements ();
28 Link_array<Music> note_evs_;
29 Link_array<Audio_note> notes_;
33 Drum_note_performer::Drum_note_performer ()
38 Drum_note_performer::create_audio_elements ()
41 if (!tab) tab = get_property ("drumPitchTable");
43 while (note_evs_.size ())
45 Music *n = note_evs_.pop ();
46 SCM sym = n->get_property ("drum-type");
49 if (scm_is_symbol (sym)
50 && (scm_hash_table_p (tab) == SCM_BOOL_T))
51 defn = scm_hashq_ref (tab, sym, SCM_EOL);
53 if (Pitch *pit = unsmob_pitch (defn))
55 Audio_note *p = new Audio_note (*pit, n->get_length (), 0);
56 Audio_element_info info (p, n);
57 announce_element (info);
66 Drum_note_performer::stop_translation_timestep ()
68 // why don't grace notes show up here?
69 // --> grace notes effectively do not get delayed
70 Moment now = now_mom ();
71 for (int i = 0; i < notes_.size (); i++)
73 play_element (notes_[i]);
80 Drum_note_performer::try_music (Music *ev)
82 if (ev->is_mus_type ("note-event"))
87 else if (ev->is_mus_type ("busy-playing-event"))
88 return note_evs_.size ();
93 #include "translator.icc"
95 ADD_TRANSLATOR (Drum_note_performer,
96 "Play drum notes.", "",
97 "note-event busy-playing-event", "", "", "");