]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-performer.cc
(DECLARE_EVENT_SWALLOWER): ENTER_DESCRIPTION -> ADD_TRANSLATOR
[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--2004 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
20 ADD_TRANSLATOR (Score_performer,
21 /* descr */       "",
22 /* creats*/       "",
23 /* accepts */     "",
24 /* acks  */      "",
25 /* reads */       "",
26 /* write */       "");
27
28
29 Score_performer::Score_performer ()
30 {
31   performance_ = 0;
32 }
33
34
35 Score_performer::~Score_performer ()
36 {
37 }
38
39 void
40 Score_performer::play_element (Audio_element * p)
41 {
42   if (Audio_item * i = dynamic_cast<Audio_item *> (p)) 
43     {
44       audio_column_->add_audio_item (i);
45     }
46   performance_->add_element (p);
47 }
48
49 void
50 Score_performer::announce_element (Audio_element_info info)
51 {
52   announce_infos_.push (info);
53 }
54
55 void 
56 Score_performer::prepare (Moment m)
57 {
58   audio_column_ = new Audio_column (m);
59   play_element (audio_column_);
60   recurse_over_translators (context (), &Translator::start_translation_timestep, UP);
61 }
62
63 void
64 Score_performer::finish ()
65 {
66   recurse_over_translators (context (), &Translator::finalize, UP);
67 }
68   
69 void 
70 Score_performer::one_time_step ()
71 {
72   recurse_over_translators (context (), &Performer::process_music, UP);
73   recurse_over_translators (context (), &Performer::do_announces, UP);
74   recurse_over_translators (context (), &Translator::stop_translation_timestep, UP);
75 }
76
77 int
78 Score_performer::get_tempo () const
79 {
80   return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
81 }
82
83
84 Music_output *
85 Score_performer::get_output ()
86 {
87   Music_output * o = performance_;
88   performance_ = 0;
89   return o;
90 }
91
92 void
93 Score_performer::initialize ()
94 {
95   performance_ = new Performance;
96   performance_->midi_ = get_output_def ();
97
98   Translator_group::initialize ();
99 }