2 staff-performer.cc -- implement Staff_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "translator-group.hh"
11 #include "audio-column.hh"
12 #include "audio-item.hh"
13 #include "audio-staff.hh"
14 #include "performer-group-performer.hh"
16 /** Perform a staff. Individual notes should have their instrument
17 (staff-wide) set, so we override play_element()
20 class Staff_performer : public Performer_group_performer
23 VIRTUAL_COPY_CONS(Translator);
29 String new_instrument_str ();
30 String instrument_str_;
33 virtual void play_element (Audio_element* p);
34 virtual void do_removal_processing ();
35 virtual void do_creation_processing ();
36 virtual void create_grobs ();
37 virtual void stop_translation_timestep ();
40 Audio_staff* audio_staff_p_;
41 Audio_instrument* instrument_p_;
42 Audio_text* instrument_name_p_;
44 Audio_tempo* tempo_p_;
47 ADD_THIS_TRANSLATOR (Staff_performer);
49 Staff_performer::Staff_performer ()
53 instrument_name_p_ = 0;
58 Staff_performer::~Staff_performer ()
63 Staff_performer::do_creation_processing ()
65 audio_staff_p_ = new Audio_staff;
66 announce_element (Audio_element_info (audio_staff_p_, 0));
68 name_p_ = new Audio_text (Audio_text::TRACK_NAME, id_str_);
69 announce_element (Audio_element_info (name_p_, 0));
71 tempo_p_ = new Audio_tempo (get_tempo_i ());
72 announce_element (Audio_element_info (tempo_p_, 0));
74 Performer_group_performer::do_creation_processing ();
78 Staff_performer::create_grobs ()
80 String str = new_instrument_str ();
83 instrument_name_p_ = new Audio_text (Audio_text::INSTRUMENT_NAME, str);
84 announce_element (Audio_element_info (instrument_name_p_, 0));
85 instrument_p_ = new Audio_instrument (str);
86 announce_element (Audio_element_info (instrument_p_, 0));
91 Staff_performer::stop_translation_timestep ()
95 play_element (name_p_);
100 play_element (tempo_p_);
103 if (instrument_name_p_)
105 play_element (instrument_name_p_);
106 instrument_name_p_ = 0;
110 play_element (instrument_p_);
113 Performer_group_performer::stop_translation_timestep ();
117 Staff_performer::do_removal_processing ()
119 Performer_group_performer::do_removal_processing ();
120 Performer::play_element (audio_staff_p_);
125 Staff_performer::new_instrument_str ()
127 // mustn't ask Score for instrument: it will return piano!
128 SCM minstr = get_property (ly_symbol2scm ("midiInstrument"));
130 if (!gh_string_p(minstr))
131 minstr = get_property (ly_symbol2scm ("instrument"));
133 if (!gh_string_p (minstr)
134 || ly_scm2string (minstr) == instrument_str_)
137 instrument_str_ = ly_scm2string (minstr);
139 return instrument_str_;
143 Staff_performer::play_element (Audio_element* p)
145 if (Audio_item *ai = dynamic_cast<Audio_item *> (p))
147 audio_staff_p_->add_audio_item (ai);
149 Performer::play_element (p);