2 note-performer.cc -- implement 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"
17 Convert evs to audio notes.
19 class Note_performer : public Performer {
21 TRANSLATOR_DECLARATIONS (Note_performer);
24 virtual bool try_music (Music *ev) ;
26 virtual void stop_translation_timestep ();
27 virtual void create_audio_elements ();
30 Link_array<Music> note_evs_;
31 Link_array<Audio_note> notes_;
32 Link_array<Audio_note> delayeds_;
36 Note_performer::create_audio_elements ()
38 if (note_evs_.size ())
42 SCM prop = get_property ("instrumentTransposition");
43 if (unsmob_pitch (prop))
44 transposing = unsmob_pitch (prop)->semitone_pitch ();
46 while (note_evs_.size ())
48 Music* n = note_evs_.pop ();
49 SCM pit = n->get_property ("pitch");
51 if (Pitch * pitp = unsmob_pitch (pit))
53 Audio_note* p = new Audio_note (*pitp, n->get_length (), - transposing);
54 Audio_element_info info (p, n);
55 announce_element (info);
65 Note_performer::stop_translation_timestep ()
67 // why don't grace notes show up here?
68 // --> grace notes effectively do not get delayed
69 Global_context * global = get_global_context ();
70 for (int i=0; i < notes_.size (); i++)
72 Audio_note* n = notes_[i];
73 Moment m= n->delayed_until_mom_;
76 global->add_moment_to_process (m);
84 Moment now = now_mom ();
85 for (int i=0; i < notes_.size (); i++)
87 play_element (notes_[i]);
91 for (int i=0; i < delayeds_.size (); i++)
93 Audio_note* n = delayeds_[i];
94 if (n->delayed_until_mom_ <= now)
105 Note_performer::try_music (Music* ev)
107 if (ev->is_mus_type ("note-event"))
112 else if (ev->is_mus_type ("busy-playing-event"))
113 return note_evs_.size ();
118 ENTER_DESCRIPTION (Note_performer,"","",
119 "note-event busy-playing-event","","","");
121 Note_performer::Note_performer ()