lilypond-1.1.67
[lilypond.git] / lily / staff-performer.cc
blob927285702be46cd4ef00e8c357ff03ce91492a45
1 /*
2 staff-performer.cc -- implement Staff_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "staff-performer.hh"
10 #include "translator-group.hh"
11 #include "debug.hh"
12 #include "audio-column.hh"
13 #include "audio-item.hh"
14 #include "audio-staff.hh"
17 ADD_THIS_TRANSLATOR (Staff_performer);
19 Staff_performer::Staff_performer ()
21 audio_staff_p_ = 0;
22 instrument_p_ = 0;
23 instrument_name_p_ = 0;
24 name_p_ = 0;
25 tempo_p_ = 0;
28 Staff_performer::~Staff_performer ()
32 void
33 Staff_performer::do_creation_processing ()
35 audio_staff_p_ = new Audio_staff;
36 announce_element (Audio_element_info (audio_staff_p_, 0));
38 name_p_ = new Audio_text (Audio_text::TRACK_NAME, id_str_);
39 announce_element (Audio_element_info (name_p_, 0));
41 tempo_p_ = new Audio_tempo (get_tempo_i ());
42 announce_element (Audio_element_info (tempo_p_, 0));
44 Performer_group_performer::do_creation_processing ();
47 void
48 Staff_performer::do_process_requests ()
50 String str = new_instrument_str ();
51 if (str.length_i ())
53 instrument_name_p_ = new Audio_text (Audio_text::INSTRUMENT_NAME, str);
54 announce_element (Audio_element_info (instrument_name_p_, 0));
55 instrument_p_ = new Audio_instrument (str);
56 announce_element (Audio_element_info (instrument_p_, 0));
58 Performer_group_performer::do_process_requests ();
61 void
62 Staff_performer::do_pre_move_processing ()
64 if (name_p_)
66 play_element (name_p_);
67 name_p_ = 0;
69 if (tempo_p_)
71 play_element (tempo_p_);
72 tempo_p_ = 0;
74 if (instrument_name_p_)
76 play_element (instrument_name_p_);
77 instrument_name_p_ = 0;
79 if (instrument_p_)
81 play_element (instrument_p_);
82 instrument_p_ = 0;
84 Performer_group_performer::do_pre_move_processing ();
87 void
88 Staff_performer::do_removal_processing ()
90 Performer_group_performer::do_removal_processing ();
91 Performer::play_element (audio_staff_p_);
92 audio_staff_p_ = 0;
95 String
96 Staff_performer::new_instrument_str ()
98 // mustn't ask Score for instrument: it will return piano!
99 String str = get_property ("midiInstrument", 0);
100 if (!str.length_i ())
101 str = get_property ("instrument", 0);
102 if (str == instrument_str_)
103 return "";
105 instrument_str_ = str;
107 return instrument_str_;
109 /* ugh, but can 't
110 if (properties_dict_.elem_b ("instrument"))
111 return properties_dict_["instrument"];
112 return "";
116 void
117 Staff_performer::play_element (Audio_element* p)
119 if (Audio_item *ai = dynamic_cast<Audio_item *> (p))
121 audio_staff_p_->add_audio_item (ai);
123 Performer::play_element (p);