]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-performer.cc
(DECLARE_BASE_SMOBS): add methods
[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                 /* descr */ "",
23                 /* creats*/ "",
24                 /* accepts */ "",
25                 /* reads */ "",
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     {
42       audio_column_->add_audio_item (i);
43     }
44   performance_->add_element (p);
45 }
46
47 void
48 Score_performer::announce_element (Audio_element_info info)
49 {
50   announce_infos_.push (info);
51 }
52
53 void
54 Score_performer::prepare (Moment m)
55 {
56   audio_column_ = new Audio_column (m);
57   play_element (audio_column_);
58   precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP);
59 }
60
61 void
62 Score_performer::finish ()
63 {
64   recurse_over_translators (context (),
65                             &Translator::finalize,
66                             &Translator_group::finalize,
67                             UP);
68 }
69
70 void
71 Score_performer::one_time_step ()
72 {
73   precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
74   do_announces ();
75   precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
76 }
77
78 int
79 Score_performer::get_tempo () const
80 {
81   return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
82 }
83
84 SCM
85 Score_performer::get_output ()
86 {
87   Music_output *o = performance_;
88   performance_ = 0;
89   return o->self_scm ();
90 }
91
92 void
93 Score_performer::derived_mark () const
94 {
95   if (performance_)
96     scm_gc_mark (performance_->self_scm ());
97
98   Score_translator::derived_mark ();
99   Performer_group_performer::derived_mark ();
100 }
101
102 void
103 Score_performer::initialize ()
104 {
105   performance_ = new Performance;
106   performance_->unprotect ();
107   performance_->midi_ = context ()->get_output_def ();
108
109   Translator_group::initialize ();
110 }