]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-performer.cc
release: 1.3.108
[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           Pitch pit =  * unsmob_pitch (n->get_mus_property ("pitch"));
40           Audio_note* p = new Audio_note (pit,  n->length_mom (), transposing_i);
41           Audio_element_info info (p, n);
42           announce_element (info);
43           note_p_arr_.push (p);
44         }
45     }
46 }
47
48 void
49 Note_performer::process_acknowledged ()
50 {
51 }
52
53 Global_translator*
54 Note_performer::global_translator_l ()
55 {
56   Translator *t = this;
57   Global_translator *global_l =0;
58   do
59     {
60       t = t->daddy_trans_l_ ;
61       global_l = dynamic_cast<Global_translator*> (t);
62     }
63   while (!global_l);
64
65   return global_l;
66 }
67
68
69 void
70 Note_performer::do_pre_move_processing ()
71 {
72
73   // why don't grace notes show up here?
74   // --> grace notes effectively do not get delayed
75   Global_translator* global_l = global_translator_l ();
76   for (int i=0; i < note_p_arr_.size (); i++)
77     {
78       Audio_note* n = note_p_arr_[i];
79       if (Moment m= n->delayed_until_mom_)
80         {
81           global_l->add_moment_to_process (m);
82           delayed_p_arr_.push (n);
83           note_p_arr_[i] = 0;
84           note_p_arr_.del (i);
85           i--;
86         }
87     }
88
89   Moment now = now_mom ();
90   for (int i=0; i < note_p_arr_.size (); i++)
91     {
92       play_element (note_p_arr_[i]);
93     }
94   note_p_arr_.clear ();
95   note_req_l_arr_.clear ();
96   for (int i=0; i < delayed_p_arr_.size (); i++)
97     {
98       Audio_note* n = delayed_p_arr_[i];
99       if (n->delayed_until_mom_ <= now)
100         {
101           play_element (n);
102           delayed_p_arr_[i] = 0;
103           delayed_p_arr_.del (i);
104           i--;
105         }
106     }
107 }
108  
109 bool
110 Note_performer::do_try_music (Music* req_l)
111 {
112   if (Note_req *nr = dynamic_cast <Note_req *> (req_l))
113     {
114       note_req_l_arr_.push (nr);
115       return true;
116     }
117   return false;
118 }