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