2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2001 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "musical-request.hh"
11 #include "audio-item.hh"
12 #include "audio-column.hh"
13 #include "global-translator.hh"
17 Convert reqs to audio notes.
19 class Note_performer : public Performer {
21 TRANSLATOR_DECLARATIONS(Note_performer);
24 virtual bool try_music (Music *req_l) ;
26 virtual void stop_translation_timestep ();
27 virtual void create_audio_elements ();
28 Global_translator* global_translator_l ();
31 Array<Note_req*> note_req_l_arr_;
32 Array<Audio_note*> note_p_arr_;
33 Array<Audio_note*> delayed_p_arr_;
37 Note_performer::create_audio_elements ()
39 if (note_req_l_arr_.size ())
41 int transposing_i = 0;
43 SCM prop = get_property ("transposing");
44 if (gh_number_p (prop))
45 transposing_i = gh_scm2int (prop);
47 while (note_req_l_arr_.size ())
49 Note_req* n = note_req_l_arr_.pop ();
50 Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch"));
51 Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i);
52 Audio_element_info info (p, n);
53 announce_element (info);
56 note_req_l_arr_.clear ();
61 Note_performer::global_translator_l ()
64 Global_translator *global_l =0;
67 t = t->daddy_trans_l_ ;
68 global_l = dynamic_cast<Global_translator*> (t);
77 Note_performer::stop_translation_timestep ()
80 // why don't grace notes show up here?
81 // --> grace notes effectively do not get delayed
82 Global_translator* global_l = global_translator_l ();
83 for (int i=0; i < note_p_arr_.size (); i++)
85 Audio_note* n = note_p_arr_[i];
86 Moment m= n->delayed_until_mom_;
89 global_l->add_moment_to_process (m);
90 delayed_p_arr_.push (n);
97 Moment now = now_mom ();
98 for (int i=0; i < note_p_arr_.size (); i++)
100 play_element (note_p_arr_[i]);
102 note_p_arr_.clear ();
103 note_req_l_arr_.clear ();
104 for (int i=0; i < delayed_p_arr_.size (); i++)
106 Audio_note* n = delayed_p_arr_[i];
107 if (n->delayed_until_mom_ <= now)
110 delayed_p_arr_[i] = 0;
111 delayed_p_arr_.del (i);
118 Note_performer::try_music (Music* req_l)
120 if (Note_req *nr = dynamic_cast <Note_req *> (req_l))
122 note_req_l_arr_.push (nr);
128 ENTER_DESCRIPTION(Note_performer,"","","","","");
130 Note_performer::Note_performer()