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"
11 #include "audio-item.hh"
12 #include "audio-column.hh"
13 #include "global-context.hh"
16 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 ();
25 Link_array
<Music
> note_evs_
;
26 Link_array
<Audio_note
> notes_
;
27 Link_array
<Audio_note
> delayeds_
;
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 (ly_c_symbol_p (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 Global_context
* global
= get_global_context ();
64 for (int i
=0; i
< notes_
.size (); i
++)
66 Audio_note
* n
= notes_
[i
];
67 Moment m
= n
->delayed_until_mom_
;
70 global
->add_moment_to_process (m
);
78 Moment now
= now_mom ();
79 for (int i
=0; i
< notes_
.size (); i
++)
81 play_element (notes_
[i
]);
85 for (int i
=0; i
< delayeds_
.size (); i
++)
87 Audio_note
* n
= delayeds_
[i
];
88 if (n
->delayed_until_mom_
<= now
)
99 Drum_note_performer::try_music (Music
* ev
)
101 if (ev
->is_mus_type ("note-event"))
106 else if (ev
->is_mus_type ("busy-playing-event"))
107 return note_evs_
.size ();
112 ENTER_DESCRIPTION (Drum_note_performer
,
113 "Play drum notes.","",
114 "note-event busy-playing-event","","","");
116 Drum_note_performer::Drum_note_performer ()