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"
18 class Note_performer : public Performer
21 TRANSLATOR_DECLARATIONS (Note_performer);
24 void stop_translation_timestep ();
25 void process_music ();
27 DECLARE_TRANSLATOR_LISTENER (note);
29 vector<Stream_event*> note_evs_;
30 vector<Audio_note*> notes_;
33 vector<Audio_note*> last_notes_;
39 Note_performer::process_music ()
41 if (!note_evs_.size ())
45 SCM prop = get_property ("instrumentTransposition");
46 if (unsmob_pitch (prop))
47 transposing = *unsmob_pitch (prop);
49 for (vsize i = 0; i < note_evs_.size (); i ++)
51 Stream_event *n = note_evs_[i];
52 SCM pit = n->get_property ("pitch");
54 if (Pitch *pitp = unsmob_pitch (pit))
56 SCM articulations = n->get_property ("articulations");
57 Stream_event *tie_event = 0;
58 for (SCM s = articulations;
59 !tie_event && scm_is_pair (s);
62 Stream_event *ev = unsmob_stream_event (scm_car (s));
66 if (ev->in_event_class ("tie-event"))
70 Moment len = get_event_length (n);
71 if (now_mom ().grace_part_)
73 len.grace_part_ = len.main_part_;
74 len.main_part_ = Rational (0);
77 Audio_note *p = new Audio_note (*pitp, len,
78 tie_event, transposing.negated ());
79 Audio_element_info info (p, n);
80 announce_element (info);
84 shorten previous note.
86 if (now_mom ().grace_part_)
88 if (last_start_.grace_part_ == Rational (0))
90 for (vsize i = 0; i < last_notes_.size (); i++)
91 last_notes_[i]->length_mom_ += Moment (0,
92 now_mom().grace_part_);
100 Note_performer::stop_translation_timestep ()
102 if (note_evs_.size ())
104 last_notes_ = notes_;
105 last_start_ = now_mom ();
112 IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note)
114 Note_performer::listen_note (Stream_event *ev)
116 note_evs_.push_back (ev);
119 ADD_TRANSLATOR (Note_performer, "", "",
122 Note_performer::Note_performer ()