2 note-performer.cc -- implement Note_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2003 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.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 TRANSLATOR_DECLARATIONS(Note_performer
);
24 virtual bool try_music (Music
*req
) ;
26 virtual void stop_translation_timestep ();
27 virtual void create_audio_elements ();
28 Global_translator
* get_global_translator ();
31 Link_array
<Music
> note_reqs_
;
32 Link_array
<Audio_note
> notes_
;
33 Link_array
<Audio_note
> delayeds_
;
37 Note_performer::create_audio_elements ()
39 if (note_reqs_
.size ())
41 int transposing_i
= 0;
43 SCM prop
= get_property ("transposing");
44 if (gh_number_p (prop
))
45 transposing_i
= gh_scm2int (prop
);
47 while (note_reqs_
.size ())
49 Music
* n
= note_reqs_
.pop ();
50 Pitch pit
= * unsmob_pitch (n
->get_mus_property ("pitch"));
51 Audio_note
* p
= new Audio_note (pit
, n
->get_length (), transposing_i
);
52 Audio_element_info
info (p
, n
);
53 announce_element (info
);
61 Note_performer::get_global_translator ()
64 Global_translator
*global
=0;
68 global
= dynamic_cast<Global_translator
*> (t
);
77 Note_performer::stop_translation_timestep ()
80 // why don't grace notes show up here?
81 // --> grace notes effectively do not get delayed
82 Global_translator
* global
= get_global_translator ();
83 for (int i
=0; i
< notes_
.size (); i
++)
85 Audio_note
* n
= notes_
[i
];
86 Moment m
= n
->delayed_until_mom_
;
89 global
->add_moment_to_process (m
);
97 Moment now
= now_mom ();
98 for (int i
=0; i
< notes_
.size (); i
++)
100 play_element (notes_
[i
]);
104 for (int i
=0; i
< delayeds_
.size (); i
++)
106 Audio_note
* n
= delayeds_
[i
];
107 if (n
->delayed_until_mom_
<= now
)
118 Note_performer::try_music (Music
* req
)
120 if (req
->is_mus_type ("note-event"))
122 note_reqs_
.push (req
);
128 ENTER_DESCRIPTION(Note_performer
,"","","note-event","","","");
130 Note_performer::Note_performer()