.ly version update.
[lilypond.git] / lily / score-performer.cc
blobee48102cbb79f47d39c853e36ae4a5ee6ddae130
1 /*
2 score-performer.cc -- implement Score_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "score-performer.hh"
10 #include "midi-def.hh"
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 "translator-def.hh"
21 ENTER_DESCRIPTION(Score_performer,
22 /* descr */ "",
23 /* creats*/ "",
24 /* accepts */ "",
25 /* acks */ "",
26 /* reads */ "",
27 /* write */ "");
30 Score_performer::Score_performer ()
32 performance_ = 0;
36 Score_performer::~Score_performer ()
40 void
41 Score_performer::play_element (Audio_element * p)
43 if (Audio_item * i=dynamic_cast<Audio_item *> (p))
45 audio_column_->add_audio_item (i);
47 performance_->add_element (p);
50 void
51 Score_performer::announce_element (Audio_element_info info)
53 announce_infos_.push (info);
57 huh?
58 copied from score-engraver, but
59 this way staff gets in list twice
60 if (Audio_item* i = dynamic_cast<Audio_item*> (info.elem_))
61 performance_->add_element (i);
65 void
66 Score_performer::prepare (Moment m)
68 Global_translator::prepare (m);
69 audio_column_ = new Audio_column (m);
70 play_element (audio_column_);
71 start_translation_timestep ();
75 void
76 Score_performer::one_time_step ()
78 // fixme: put this back.
79 // process_music ();
80 do_announces ();
81 stop_translation_timestep ();
82 check_removal ();
85 void
86 Score_performer::start ()
91 int
92 Score_performer::get_tempo () const
94 return performance_->midi_->get_tempo (Moment (Rational (1, 4)));
97 void
98 Score_performer::finish ()
100 check_removal ();
101 removal_processing ();
104 Music_output *
105 Score_performer::get_output ()
107 Music_output * o = performance_;
108 performance_ =0;
109 return o;
112 void
113 Score_performer::initialize ()
115 unsmob_translator_def (definition_)->apply_property_operations (this);
116 assert (dynamic_cast<Midi_def *> (output_def_));
117 performance_ = new Performance;
118 performance_->midi_ = dynamic_cast<Midi_def*> (output_def_);
120 Translator_group::initialize ();