2 note-performer.cc -- implement Drum_note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2004 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 {
17 TRANSLATOR_DECLARATIONS (Drum_note_performer);
20 virtual bool try_music (Music *ev) ;
21 virtual void stop_translation_timestep ();
22 virtual void create_audio_elements ();
24 Link_array<Music> note_evs_;
25 Link_array<Audio_note> notes_;
26 Link_array<Audio_note> delayeds_;
30 Drum_note_performer::create_audio_elements ()
33 if (!tab) tab = get_property ("drumPitchTable");
35 while (note_evs_.size ())
37 Music* n = note_evs_.pop ();
38 SCM sym = n->get_property ("drum-type");
41 if (scm_is_symbol (sym)
42 && (scm_hash_table_p (tab) == SCM_BOOL_T))
43 defn = scm_hashq_ref (tab, sym, SCM_EOL);
45 if (Pitch * pit = unsmob_pitch (defn))
47 Audio_note* p = new Audio_note (*pit, n->get_length (), 0);
48 Audio_element_info info (p, n);
49 announce_element (info);
58 Drum_note_performer::stop_translation_timestep ()
60 // why don't grace notes show up here?
61 // --> grace notes effectively do not get delayed
62 Global_context * global = get_global_context ();
63 for (int i=0; i < notes_.size (); i++)
65 Audio_note* n = notes_[i];
66 Moment m= n->delayed_until_mom_;
69 global->add_moment_to_process (m);
77 Moment now = now_mom ();
78 for (int i=0; i < notes_.size (); i++)
80 play_element (notes_[i]);
84 for (int i=0; i < delayeds_.size (); i++)
86 Audio_note* n = delayeds_[i];
87 if (n->delayed_until_mom_ <= now)
98 Drum_note_performer::try_music (Music* ev)
100 if (ev->is_mus_type ("note-event"))
105 else if (ev->is_mus_type ("busy-playing-event"))
106 return note_evs_.size ();
111 ENTER_DESCRIPTION (Drum_note_performer,
112 "Play drum notes.","",
113 "note-event busy-playing-event","","","");
115 Drum_note_performer::Drum_note_performer ()