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 VIRTUAL_COPY_CONS (Translator
);
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_
;
36 ADD_THIS_TRANSLATOR (Note_performer
);
39 Note_performer::create_audio_elements ()
41 if (note_req_l_arr_
.size ())
43 int transposing_i
= 0;
45 SCM prop
= get_property ("transposing");
46 if (gh_number_p (prop
))
47 transposing_i
= gh_scm2int (prop
);
49 while (note_req_l_arr_
.size ())
51 Note_req
* n
= note_req_l_arr_
.pop ();
52 Pitch pit
= * unsmob_pitch (n
->get_mus_property ("pitch"));
53 Audio_note
* p
= new Audio_note (pit
, n
->length_mom (), transposing_i
);
54 Audio_element_info
info (p
, n
);
55 announce_element (info
);
58 note_req_l_arr_
.clear ();
63 Note_performer::global_translator_l ()
66 Global_translator
*global_l
=0;
69 t
= t
->daddy_trans_l_
;
70 global_l
= dynamic_cast<Global_translator
*> (t
);
79 Note_performer::stop_translation_timestep ()
82 // why don't grace notes show up here?
83 // --> grace notes effectively do not get delayed
84 Global_translator
* global_l
= global_translator_l ();
85 for (int i
=0; i
< note_p_arr_
.size (); i
++)
87 Audio_note
* n
= note_p_arr_
[i
];
88 if (Moment m
= n
->delayed_until_mom_
)
90 global_l
->add_moment_to_process (m
);
91 delayed_p_arr_
.push (n
);
98 Moment now
= now_mom ();
99 for (int i
=0; i
< note_p_arr_
.size (); i
++)
101 play_element (note_p_arr_
[i
]);
103 note_p_arr_
.clear ();
104 note_req_l_arr_
.clear ();
105 for (int i
=0; i
< delayed_p_arr_
.size (); i
++)
107 Audio_note
* n
= delayed_p_arr_
[i
];
108 if (n
->delayed_until_mom_
<= now
)
111 delayed_p_arr_
[i
] = 0;
112 delayed_p_arr_
.del (i
);
119 Note_performer::try_music (Music
* req_l
)
121 if (Note_req
*nr
= dynamic_cast <Note_req
*> (req_l
))
123 note_req_l_arr_
.push (nr
);