lilypond-1.3.28
[lilypond.git] / lily / note-performer.cc
blobd2cfe8dea83e87989e4d7e55c7bec5f3ec775d2d
1 /*
2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "note-performer.hh"
10 #include "musical-request.hh"
11 #include "audio-item.hh"
12 #include "audio-column.hh"
13 #include "global-translator.hh"
14 #include "debug.hh"
17 ADD_THIS_TRANSLATOR (Note_performer);
19 Note_performer::Note_performer ()
23 void
24 Note_performer::do_print () const
26 #ifndef NPRINT
27 if (note_req_l_arr_.size()>0)
28 for(int i=0;i<note_req_l_arr_.size();i++)
29 note_req_l_arr_[i]->print ();
30 #endif
33 void
34 Note_performer::do_process_requests ()
36 if (note_req_l_arr_.size ())
38 int transposing_i = 0;
39 //urg
40 SCM prop = get_property ("transposing", 0);
41 if (gh_number_p(prop))
42 transposing_i = gh_scm2int (prop);
44 while (note_req_l_arr_.size ())
46 Note_req* n = note_req_l_arr_.pop ();
47 Audio_note* p = new Audio_note (n->pitch_, n->length_mom (), transposing_i);
48 Audio_element_info info (p, n);
49 announce_element (info);
50 note_p_arr_.push (p);
55 void
56 Note_performer::process_acknowledged ()
60 Global_translator*
61 Note_performer::global_translator_l ()
63 Translator *t = this;
64 Global_translator *global_l =0;
67 t = t->daddy_trans_l_ ;
68 global_l = dynamic_cast<Global_translator*> (t);
70 while (!global_l);
72 return global_l;
76 void
77 Note_performer::do_pre_move_processing ()
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 if (Moment m= n->delayed_until_mom_)
88 global_l->add_moment_to_process (m);
89 delayed_p_arr_.push (n);
90 note_p_arr_[i] = 0;
91 note_p_arr_.del (i);
92 i--;
96 Moment now = now_mom ();
97 for (int i=0; i < note_p_arr_.size (); i++)
99 play_element (note_p_arr_[i]);
101 note_p_arr_.clear ();
102 note_req_l_arr_.clear ();
103 for (int i=0; i < delayed_p_arr_.size (); i++)
105 Audio_note* n = delayed_p_arr_[i];
106 if (n->delayed_until_mom_ <= now)
108 play_element (n);
109 delayed_p_arr_[i] = 0;
110 delayed_p_arr_.del (i);
111 i--;
116 bool
117 Note_performer::do_try_music (Music* req_l)
119 if (Note_req *nr = dynamic_cast <Note_req *> (req_l))
121 note_req_l_arr_.push (nr);
122 return true;
124 return false;