lilypond-1.1.55
[lilypond.git] / lily / staff-performer.cc
blob6628fbeca0b52d482e18c454bbbf532992ccbd20
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;
24 Staff_performer::~Staff_performer ()
26 delete audio_staff_p_;
29 void
30 Staff_performer::do_creation_processing ()
32 audio_staff_p_ = new Audio_staff;
34 play (new Audio_text (Audio_text::TRACK_NAME, id_str_));
36 #if 1
37 String str = new_instrument_str ();
38 if (str.length_i ())
39 // instrument description
40 play (new Audio_text (Audio_text::INSTRUMENT_NAME, str));
41 #endif
43 // tempo
44 play (new Audio_tempo (get_tempo_i ()));
46 #if 1
47 if (str.length_i ())
48 // instrument
49 play (new Audio_instrument (str));
50 #endif
52 Performer_group_performer::do_creation_processing ();
55 void
56 Staff_performer::do_process_requests ()
58 String str = new_instrument_str ();
59 if (str.length_i ())
61 play (new Audio_text (Audio_text::INSTRUMENT_NAME, str));
62 play (new Audio_instrument (str));
64 Performer_group_performer::do_process_requests ();
68 void
69 Staff_performer::do_removal_processing ()
71 Performer_group_performer::do_removal_processing ();
72 Performer::play (audio_staff_p_);
73 audio_staff_p_ = 0;
76 String
77 Staff_performer::new_instrument_str ()
79 // mustn't ask Score for instrument: it will return piano!
80 String str = get_property ("midiInstrument", 0);
81 if (!str.length_i ())
82 str = get_property ("instrument", 0);
83 if (str == instrument_str_)
84 return "";
86 instrument_str_ = str;
88 return instrument_str_;
90 /* ugh, but can 't
91 if (properties_dict_.elem_b ("instrument"))
92 return properties_dict_["instrument"];
93 return "";
97 void
98 Staff_performer::play (Audio_element* p)
100 if (Audio_item *ai = dynamic_cast<Audio_item *> (p))
102 audio_staff_p_->add_audio_item (ai);
104 Performer::play (p);