]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-performer.cc
ea2926c5bc45b176a162f5c4d065587201b8c85a
[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--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
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 "debug.hh"
17 #include "translator-def.hh"
18
19
20
21 ENTER_DESCRIPTION(Score_performer,
22 /* descr */       "",
23 /* creats*/       "",
24 /* acks  */       "",
25 /* reads */       "",
26 /* write */       "");
27
28
29 Score_performer::Score_performer ()
30 {
31   performance_p_ = 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_l_->add_audio_item (i);
45     }
46   performance_p_->add_element (p);
47 }
48
49 void
50 Score_performer::announce_element (Audio_element_info info)
51 {
52   announce_info_arr_.push (info);
53
54
55   /*
56     huh?
57     copied from score-engraver, but
58     this way staff gets in list twice
59   if (Audio_item* i = dynamic_cast<Audio_item*> (info.elem_l_))
60     performance_p_->add_element (i);
61   */
62 }
63
64 void 
65 Score_performer::prepare (Moment m)
66 {
67   Global_translator::prepare (m);
68   audio_column_l_ = new Audio_column (m);
69   play_element (audio_column_l_);
70   start_translation_timestep ();
71 }
72
73
74 void 
75 Score_performer::one_time_step ()
76 {
77   // fixme: put this back.
78   // process_music ();
79   announces ();
80   stop_translation_timestep ();
81   check_removal ();
82 }
83
84 void
85 Score_performer::start ()
86 {
87 }
88
89
90 int
91 Score_performer::get_tempo_i () const
92 {
93   return performance_p_->midi_l_->get_tempo_i (Moment (Rational (1, 4)));
94 }
95
96 void
97 Score_performer::finish ()
98 {
99   check_removal ();
100   removal_processing ();
101 }
102
103 Music_output *
104 Score_performer::get_output_p ()
105 {
106   Music_output * o = performance_p_;
107   performance_p_ =0;
108   return o;
109 }
110
111 void
112 Score_performer::initialize ()
113 {
114   unsmob_translator_def (definition_)->apply_property_operations (this);
115   assert (dynamic_cast<Midi_def *> (output_def_l_));
116   performance_p_ = new Performance;
117   performance_p_->midi_l_ = dynamic_cast<Midi_def*> (output_def_l_);
118
119   Translator_group::initialize ();
120 }