]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-performer.cc
release: 1.3.93
[lilypond.git] / lily / note-performer.cc
1 /*
2   note-performer.cc -- implement Note_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
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"
15
16
17 ADD_THIS_TRANSLATOR (Note_performer);
18
19 Note_performer::Note_performer ()
20 {
21 }
22
23
24
25 void 
26 Note_performer::do_process_music () 
27 {
28   if (note_req_l_arr_.size ())
29     {
30       int transposing_i = 0;
31       //urg
32       SCM prop = get_property ("transposing");
33       if (gh_number_p(prop)) 
34         transposing_i = gh_scm2int (prop);
35
36       while (note_req_l_arr_.size ())
37         {
38           Note_req* n = note_req_l_arr_.pop ();
39           Audio_note* p = new Audio_note (n->pitch_, n->length_mom (), transposing_i);
40           Audio_element_info info (p, n);
41           announce_element (info);
42           note_p_arr_.push (p);
43         }
44     }
45 }
46
47 void
48 Note_performer::process_acknowledged ()
49 {
50 }
51
52 Global_translator*
53 Note_performer::global_translator_l ()
54 {
55   Translator *t = this;
56   Global_translator *global_l =0;
57   do
58     {
59       t = t->daddy_trans_l_ ;
60       global_l = dynamic_cast<Global_translator*> (t);
61     }
62   while (!global_l);
63
64   return global_l;
65 }
66
67
68 void
69 Note_performer::do_pre_move_processing ()
70 {
71
72   // why don't grace notes show up here?
73   // --> grace notes effectively do not get delayed
74   Global_translator* global_l = global_translator_l ();
75   for (int i=0; i < note_p_arr_.size (); i++)
76     {
77       Audio_note* n = note_p_arr_[i];
78       if (Moment m= n->delayed_until_mom_)
79         {
80           global_l->add_moment_to_process (m);
81           delayed_p_arr_.push (n);
82           note_p_arr_[i] = 0;
83           note_p_arr_.del (i);
84           i--;
85         }
86     }
87
88   Moment now = now_mom ();
89   for (int i=0; i < note_p_arr_.size (); i++)
90     {
91       play_element (note_p_arr_[i]);
92     }
93   note_p_arr_.clear ();
94   note_req_l_arr_.clear ();
95   for (int i=0; i < delayed_p_arr_.size (); i++)
96     {
97       Audio_note* n = delayed_p_arr_[i];
98       if (n->delayed_until_mom_ <= now)
99         {
100           play_element (n);
101           delayed_p_arr_[i] = 0;
102           delayed_p_arr_.del (i);
103           i--;
104         }
105     }
106 }
107  
108 bool
109 Note_performer::do_try_music (Music* req_l)
110 {
111   if (Note_req *nr = dynamic_cast <Note_req *> (req_l))
112     {
113       note_req_l_arr_.push (nr);
114       return true;
115     }
116   return false;
117 }