(parse_symbol_list): Bugfix.
[lilypond/patrick.git] / lily / note-performer.cc
blob6409c77d5bacb0e26ed2fe9ef20766ec0af2a9c6
1 /*
2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2005 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 "warn.hh"
14 #include "music.hh"
16 /**
17 Convert evs to audio notes.
19 class Note_performer : public Performer
21 public:
22 TRANSLATOR_DECLARATIONS (Note_performer);
24 protected:
25 virtual bool try_music (Music *ev);
27 void stop_translation_timestep ();
28 virtual void create_audio_elements ();
30 private:
31 Link_array<Music> note_evs_;
32 Link_array<Audio_note> notes_;
35 void
36 Note_performer::create_audio_elements ()
38 if (note_evs_.size ())
40 int transposing = 0;
42 SCM prop = get_property ("instrumentTransposition");
43 if (unsmob_pitch (prop))
44 transposing = unsmob_pitch (prop)->semitone_pitch ();
46 while (note_evs_.size ())
48 Music *n = note_evs_.pop ();
49 SCM pit = n->get_property ("pitch");
51 if (Pitch *pitp = unsmob_pitch (pit))
53 Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing);
54 Audio_element_info info (p, n);
55 announce_element (info);
56 notes_.push (p);
59 note_evs_.clear ();
63 void
64 Note_performer::stop_translation_timestep ()
66 // why don't grace notes show up here?
67 // --> grace notes effectively do not get delayed
68 Moment now = now_mom ();
69 for (int i = 0; i < notes_.size (); i++)
71 play_element (notes_[i]);
73 notes_.clear ();
74 note_evs_.clear ();
77 bool
78 Note_performer::try_music (Music *ev)
80 if (ev->is_mus_type ("note-event"))
82 note_evs_.push (ev);
83 return true;
85 else if (ev->is_mus_type ("busy-playing-event"))
86 return note_evs_.size ();
88 return false;
91 #include "translator.icc"
93 ADD_TRANSLATOR (Note_performer, "", "",
94 "note-event busy-playing-event",
95 "", "");
97 Note_performer::Note_performer ()