Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / note-performer.cc
blobff3f5b3f816a2212886c726e6a3a98c0b218e04c
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1996--2011 Jan Nieuwenhuizen <janneke@gnu.org>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "performer.hh"
21 #include "audio-item.hh"
22 #include "audio-column.hh"
23 #include "global-context.hh"
24 #include "stream-event.hh"
25 #include "warn.hh"
27 #include "translator.icc"
29 class Note_performer : public Performer
31 public:
32 TRANSLATOR_DECLARATIONS (Note_performer);
34 protected:
35 void stop_translation_timestep ();
36 void process_music ();
38 DECLARE_TRANSLATOR_LISTENER (note);
39 private:
40 vector<Stream_event*> note_evs_;
41 vector<Audio_note*> notes_;
44 vector<Audio_note*> last_notes_;
45 Moment last_start_;
49 void
50 Note_performer::process_music ()
52 if (!note_evs_.size ())
53 return;
55 Pitch transposing;
56 SCM prop = get_property ("instrumentTransposition");
57 if (unsmob_pitch (prop))
58 transposing = *unsmob_pitch (prop);
60 for (vsize i = 0; i < note_evs_.size (); i ++)
62 Stream_event *n = note_evs_[i];
63 SCM pit = n->get_property ("pitch");
65 if (Pitch *pitp = unsmob_pitch (pit))
67 SCM articulations = n->get_property ("articulations");
68 Stream_event *tie_event = 0;
69 for (SCM s = articulations;
70 !tie_event && scm_is_pair (s);
71 s = scm_cdr (s))
73 Stream_event *ev = unsmob_stream_event (scm_car (s));
74 if (!ev)
75 continue;
77 if (ev->in_event_class ("tie-event"))
78 tie_event = ev;
81 Moment len = get_event_length (n, now_mom ());
83 Audio_note *p = new Audio_note (*pitp, len,
84 tie_event, transposing.negated ());
85 Audio_element_info info (p, n);
86 announce_element (info);
87 notes_.push_back (p);
90 shorten previous note.
92 if (now_mom ().grace_part_)
94 if (last_start_.grace_part_ == Rational (0))
96 for (vsize i = 0; i < last_notes_.size (); i++)
97 last_notes_[i]->length_mom_ += Moment (0,
98 now_mom().grace_part_);
105 void
106 Note_performer::stop_translation_timestep ()
108 if (note_evs_.size ())
110 last_notes_ = notes_;
111 last_start_ = now_mom ();
114 notes_.clear ();
115 note_evs_.clear ();
118 IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note)
119 void
120 Note_performer::listen_note (Stream_event *ev)
122 note_evs_.push_back (ev);
125 ADD_TRANSLATOR (Note_performer,
126 /* doc */
129 /* create */
132 /* read */
135 /* write */
139 Note_performer::Note_performer ()