2 note-performer.cc -- implement Drum_note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2006 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 #include "stream-event.hh"
16 #include "translator.icc"
19 class Drum_note_performer : public Performer
22 TRANSLATOR_DECLARATIONS (Drum_note_performer);
25 void stop_translation_timestep ();
26 void process_music ();
27 DECLARE_TRANSLATOR_LISTENER (note);
29 vector<Stream_event*> note_evs_;
30 vector<Audio_note*> notes_;
33 Drum_note_performer::Drum_note_performer ()
38 Drum_note_performer::process_music ()
40 SCM tab = get_property ("drumPitchTable");
42 while (note_evs_.size ())
44 Stream_event *n = note_evs_.back ();
45 note_evs_.pop_back ();
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 SCM articulations = n->get_property ("articulations");
57 for (SCM s = articulations;
58 !tie_event && scm_is_pair (s);
61 Music *m = unsmob_music (scm_car (s));
65 if (m->is_mus_type ("tie-event"))
69 Audio_note *p = new Audio_note (*pit, get_event_length (n),
71 Audio_element_info info (p, n);
72 announce_element (info);
81 Drum_note_performer::stop_translation_timestep ()
87 IMPLEMENT_TRANSLATOR_LISTENER (Drum_note_performer, note);
89 Drum_note_performer::listen_note (Stream_event *ev)
91 note_evs_.push_back (ev);
94 ADD_TRANSLATOR (Drum_note_performer,
95 "Play drum notes.", "",
96 "note-event", "", "");