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