]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-performer.cc
release: 0.1.45
[lilypond.git] / lily / staff-performer.cc
1 /*
2   staff-performer.cc -- implement Staff_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7  */
8
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"
15
16 IMPLEMENT_IS_TYPE_B1(Staff_performer,Performer_group_performer);
17 ADD_THIS_TRANSLATOR(Staff_performer);
18
19 Staff_performer::Staff_performer()
20 {
21   audio_staff_p_ = 0;
22 }
23
24 Staff_performer::~Staff_performer()
25 {
26   delete audio_staff_p_;
27 }
28
29 void
30 Staff_performer::do_creation_processing()
31 {
32   audio_staff_p_ = new Audio_staff;
33
34   if (instrument_str().length_i()) 
35     {
36       // staff name
37       play (new Audio_text (Audio_text::TRACK_NAME, id_str_));
38       // instrument description
39       play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str ()));
40     }
41
42   // tempo
43   play (new Audio_tempo (get_tempo_i ()));
44
45   if (instrument_str ().length_i ())
46     // instrument
47     play (new Audio_instrument (instrument_str ()));
48   Performer_group_performer::do_creation_processing ();
49 }
50
51 void
52 Staff_performer::do_removal_processing()
53 {
54   Performer_group_performer::do_removal_processing ();
55   Performer::play (audio_staff_p_);
56   audio_staff_p_ = 0;
57 }
58
59 String 
60 Staff_performer::instrument_str() 
61
62   // mustn't ask Score for instrument: it will return piano!
63   return get_property ("instrument");
64
65 /* ugh, but can't
66   if (properties_dict_.elt_b ("instrument"))
67     return properties_dict_["instrument"];
68   return "";
69 */
70 }
71
72 void 
73 Staff_performer::play (Audio_element* p)
74 {
75   if (p->is_type_b (Audio_item::static_name())) 
76     {
77       audio_staff_p_->add ((Audio_item*)p);
78     }
79   Performer::play (p);
80 }
81