]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-performer.cc
* scm/define-grob-properties.scm (all-user-grob-properties): add
[lilypond.git] / lily / score-performer.cc
1 /*
2   score-performer.cc -- implement Score_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "score-performer.hh"
10
11 #include "audio-column.hh"
12 #include "audio-item.hh"
13 #include "performance.hh"
14 #include "midi-stream.hh"
15 #include "string-convert.hh"
16 #include "warn.hh"
17 #include "context-def.hh"
18 #include "output-def.hh"
19 #include "context.hh"
20
21 ADD_TRANSLATOR_GROUP (Score_performer,
22                       /* doc */ "",
23                       /* create */ "",
24                       /* accept */ "",
25                       /* read */ "",
26                       /* write */ "");
27
28 Score_performer::Score_performer ()
29 {
30   performance_ = 0;
31 }
32
33 Score_performer::~Score_performer ()
34 {
35 }
36
37 void
38 Score_performer::play_element (Audio_element *p)
39 {
40   if (Audio_item *i = dynamic_cast<Audio_item *> (p))
41     audio_column_->add_audio_item (i);
42   performance_->add_element (p);
43 }
44
45 void
46 Score_performer::announce_element (Audio_element_info info)
47 {
48   announce_infos_.push (info);
49 }
50
51 void
52 Score_performer::prepare (Moment m)
53 {
54   audio_column_ = new Audio_column (m);
55   play_element (audio_column_);
56   precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP);
57 }
58
59 void
60 Score_performer::finish ()
61 {
62   recurse_over_translators (context (),
63                             &Translator::finalize,
64                             &Translator_group::finalize,
65                             UP);
66 }
67
68 void
69 Score_performer::one_time_step ()
70 {
71   precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
72   do_announces ();
73   precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
74 }
75
76 int
77 Score_performer::get_tempo () const
78 {
79   return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
80 }
81
82 SCM
83 Score_performer::get_output ()
84 {
85   Music_output *o = performance_;
86   performance_ = 0;
87   return o->self_scm ();
88 }
89
90 void
91 Score_performer::derived_mark () const
92 {
93   if (performance_)
94     scm_gc_mark (performance_->self_scm ());
95
96   Score_translator::derived_mark ();
97   Performer_group::derived_mark ();
98 }
99
100 void
101 Score_performer::initialize ()
102 {
103   performance_ = new Performance;
104   performance_->unprotect ();
105   performance_->midi_ = context ()->get_output_def ();
106
107   Translator_group::initialize ();
108 }