2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2008 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
, 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
);
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_
);
95 Note_performer::stop_translation_timestep ()
97 if (note_evs_
.size ())
100 last_start_
= now_mom ();
107 IMPLEMENT_TRANSLATOR_LISTENER (Note_performer
, note
)
109 Note_performer::listen_note (Stream_event
*ev
)
111 note_evs_
.push_back (ev
);
114 ADD_TRANSLATOR (Note_performer
,
128 Note_performer::Note_performer ()