2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2007 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
13 #include "stream-event.hh"
16 #include "translator.icc"
19 Convert evs to audio notes.
21 class Note_performer : public Performer
24 TRANSLATOR_DECLARATIONS (Note_performer);
27 void stop_translation_timestep ();
28 void process_music ();
30 DECLARE_TRANSLATOR_LISTENER (note);
32 vector<Stream_event*> note_evs_;
33 vector<Audio_note*> notes_;
37 Note_performer::process_music ()
39 if (note_evs_.size ())
42 SCM prop = get_property ("instrumentTransposition");
43 if (unsmob_pitch (prop))
44 transposing = *unsmob_pitch (prop);
46 while (note_evs_.size ())
48 Stream_event *n = note_evs_.back ();
49 note_evs_.pop_back ();
50 SCM pit = n->get_property ("pitch");
52 if (Pitch *pitp = unsmob_pitch (pit))
54 SCM articulations = n->get_property ("articulations");
55 Stream_event *tie_event = 0;
56 for (SCM s = articulations;
57 !tie_event && scm_is_pair (s);
60 Stream_event *ev = unsmob_stream_event (scm_car (s));
64 if (ev->in_event_class ("tie-event"))
68 Moment len = get_event_length (n);
69 if (now_mom().grace_part_)
71 len.grace_part_ = len.main_part_;
72 len.main_part_ = Rational (0);
75 Audio_note *p = new Audio_note (*pitp, len,
76 tie_event, transposing.negated ());
77 Audio_element_info info (p, n);
78 announce_element (info);
87 Note_performer::stop_translation_timestep ()
89 // why don't grace notes show up here?
90 // --> grace notes effectively do not get delayed
95 IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note)
97 Note_performer::listen_note (Stream_event *ev)
99 note_evs_.push_back (ev);
102 ADD_TRANSLATOR (Note_performer, "", "",
105 Note_performer::Note_performer ()