Layout nitpicks for notime fragment option.
[lilypond.git] / lily / note-performer.cc
blob435575da604b1b66eecf109cc0df4cf452c9e221
1 /*
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>
7 */
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
13 #include "stream-event.hh"
14 #include "warn.hh"
16 #include "translator.icc"
18 class Note_performer : public Performer
20 public:
21 TRANSLATOR_DECLARATIONS (Note_performer);
23 protected:
24 void stop_translation_timestep ();
25 void process_music ();
27 DECLARE_TRANSLATOR_LISTENER (note);
28 private:
29 vector<Stream_event*> note_evs_;
30 vector<Audio_note*> notes_;
33 vector<Audio_note*> last_notes_;
34 Moment last_start_;
38 void
39 Note_performer::process_music ()
41 if (!note_evs_.size ())
42 return;
44 Pitch transposing;
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);
60 s = scm_cdr (s))
62 Stream_event *ev = unsmob_stream_event (scm_car (s));
63 if (!ev)
64 continue;
66 if (ev->in_event_class ("tie-event"))
67 tie_event = ev;
70 Moment len = get_event_length (n, now_mom ());
72 Audio_note *p = new Audio_note (*pitp, len,
73 tie_event, transposing.negated ());
74 Audio_element_info info (p, n);
75 announce_element (info);
76 notes_.push_back (p);
79 shorten previous note.
81 if (now_mom ().grace_part_)
83 if (last_start_.grace_part_ == Rational (0))
85 for (vsize i = 0; i < last_notes_.size (); i++)
86 last_notes_[i]->length_mom_ += Moment (0,
87 now_mom().grace_part_);
94 void
95 Note_performer::stop_translation_timestep ()
97 if (note_evs_.size ())
99 last_notes_ = notes_;
100 last_start_ = now_mom ();
103 notes_.clear ();
104 note_evs_.clear ();
107 IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note)
108 void
109 Note_performer::listen_note (Stream_event *ev)
111 note_evs_.push_back (ev);
114 ADD_TRANSLATOR (Note_performer,
115 /* doc */
118 /* create */
121 /* read */
124 /* write */
128 Note_performer::Note_performer ()