]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-performer.cc
*** empty log message ***
[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 #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 "context-def.hh"
18
19
20
21 ENTER_DESCRIPTION(Score_performer,
22 /* descr */       "",
23 /* creats*/       "",
24 /* accepts */     "",
25 /* acks  */      "",
26 /* reads */       "",
27 /* write */       "");
28
29
30 Score_performer::Score_performer ()
31 {
32   performance_ = 0;
33 }
34
35
36 Score_performer::~Score_performer ()
37 {
38 }
39
40 void
41 Score_performer::play_element (Audio_element * p)
42 {
43   if (Audio_item * i=dynamic_cast<Audio_item *> (p)) 
44     {
45       audio_column_->add_audio_item (i);
46     }
47   performance_->add_element (p);
48 }
49
50 void
51 Score_performer::announce_element (Audio_element_info info)
52 {
53   announce_infos_.push (info);
54
55
56   /*
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);
62   */
63 }
64
65 void 
66 Score_performer::prepare (Moment m)
67 {
68   Global_translator::prepare (m);
69   audio_column_ = new Audio_column (m);
70   play_element (audio_column_);
71   start_translation_timestep ();
72 }
73
74
75 void 
76 Score_performer::one_time_step ()
77 {
78   process_music ();
79   do_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 () const
92 {
93   return performance_->midi_->get_tempo (Moment (Rational (1, 4)));
94 }
95
96 void
97 Score_performer::finish ()
98 {
99   check_removal ();
100   finalize ();
101 }
102
103 Music_output *
104 Score_performer::get_output ()
105 {
106   Music_output * o = performance_;
107   performance_ =0;
108   return o;
109 }
110
111 void
112 Score_performer::initialize ()
113 {
114   unsmob_context_def (definition_)->apply_default_property_operations (this);
115   performance_ = new Performance;
116   performance_->midi_ = dynamic_cast<Midi_def*> (get_output_def ());
117
118   Translator_group::initialize ();
119 }