+void
+Staff_performer::set_instrument (int channel, const string &voice)
+{
+ instrument_ = new Audio_instrument (instrument_string_);
+ instrument_->channel_ = channel;
+ announce_element (Audio_element_info (instrument_, 0));
+ Audio_staff *audio_staff = get_audio_staff (voice);
+ audio_staff->add_audio_item (instrument_);
+ SCM proc = ly_lily_module_constant ("percussion?");
+ SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.c_str ()));
+ audio_staff->percussion_ = (drums == SCM_BOOL_T);
+}
+
+void
+Staff_performer::set_instrument_name (const string &voice)
+{
+ instrument_name_ = new Audio_text (Audio_text::INSTRUMENT_NAME,
+ instrument_string_);
+ announce_element (Audio_element_info (instrument_name_, 0));
+ get_audio_staff (voice)->add_audio_item (instrument_name_);
+}
+
+void
+Staff_performer::stop_translation_timestep ()
+{
+ name_ = 0;
+ tempo_ = 0;
+ instrument_name_ = 0;
+ instrument_ = 0;
+ // For each voice with a note played in the current translation time step,
+ // check if the voice has an Audio_dynamic registered: if yes, apply this
+ // dynamic to every note played in the voice in the current translation time
+ // step.
+ for (map<string, deque<Audio_note *> >::iterator vi = note_map_.begin ();
+ vi != note_map_.end (); ++vi)
+ {
+ Audio_dynamic *d = get_dynamic (vi->first);
+ if (d)
+ {
+ for (deque<Audio_note *>::iterator ni = vi->second.begin ();
+ ni != vi->second.end (); ++ni)
+ (*ni)->dynamic_ = d;
+ }
+ }
+ note_map_.clear ();
+}
+
+void
+Staff_performer::finalize ()
+{
+ staff_map_.clear ();
+ channel_map_.clear ();
+ if (staff_performer_count_)
+ --staff_performer_count_;
+ if (0 == staff_performer_count_)
+ {
+ static_channel_map_.clear ();
+ channel_count_ = 0;
+ }
+}
+
+string
+Staff_performer::new_instrument_string ()
+{