2 recording-group-engraver.cc -- implement Recording_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2003--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
11 #include "engraver-group-engraver.hh"
12 #include "protected-scm.hh"
14 class Recording_group_engraver
: public Engraver_group_engraver
18 TRANSLATOR_DECLARATIONS (Recording_group_engraver
);
19 virtual bool try_music (Music
*m
);
20 virtual void start_translation_timestep ();
21 virtual void stop_translation_timestep ();
22 virtual void finalize ();
23 virtual void initialize ();
24 Protected_scm accumulator_
;
28 Recording_group_engraver::initialize ()
30 Engraver_group_engraver::initialize ();
34 Recording_group_engraver::Recording_group_engraver ()
39 Recording_group_engraver::start_translation_timestep ()
41 Engraver_group_engraver::start_translation_timestep ();
45 We have to do this both in initialize () and
46 start_translation_timestep (), since start_translation_timestep ()
47 isn't called on the first time-step.
53 Recording_group_engraver::start ()
55 if (!gh_pair_p (accumulator_
))
56 accumulator_
= gh_cons (SCM_EOL
, SCM_EOL
);
57 if (!gh_pair_p (gh_car (accumulator_
)))
60 Need to store transposition for every moment; transposition changes during pieces.
62 scm_set_car_x (accumulator_
, gh_cons (gh_cons (now_mom ().smobbed_copy (),
63 get_property ("instrumentTransposition")),
69 Recording_group_engraver::stop_translation_timestep ()
71 Engraver_group_engraver::stop_translation_timestep ();
72 scm_set_cdr_x (accumulator_
, gh_cons (gh_car (accumulator_
), gh_cdr (accumulator_
)));
74 scm_set_car_x (accumulator_
, SCM_EOL
);
78 Recording_group_engraver::finalize ()
80 Engraver_group_engraver::finalize ();
81 SCM proc
= get_property ("recordEventSequence");
83 if (gh_procedure_p (proc
))
84 scm_call_2 (proc
, daddy_context_
->self_scm (), gh_cdr (accumulator_
));
86 accumulator_
= SCM_EOL
;
90 Recording_group_engraver::try_music (Music
*m
)
92 bool retval
= Translator_group::try_music (m
);
94 SCM seq
= gh_cdar (accumulator_
);
95 seq
= gh_cons (gh_cons (m
->self_scm (), gh_bool2scm (retval
)),
98 scm_set_cdr_x (gh_car (accumulator_
), seq
);
104 ENTER_DESCRIPTION (Recording_group_engraver
,
105 "Engraver_group_engraver that records all music events "
106 "for this context. Calls the procedure "
107 "in @code{recordEventSequence} when finished.",
111 "recordEventSequence",