]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-performer.cc
release: 1.1.1
[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--1998 Jan Nieuwenhuizen <janneke@gnu.org>
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   play (new Audio_text (Audio_text::TRACK_NAME, id_str_));
35
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
42
43   // tempo
44   play (new Audio_tempo (get_tempo_i ()));
45
46 #if 1
47   if (str.length_i ())
48     // instrument
49     play (new Audio_instrument (str));
50 #endif
51    
52   Performer_group_performer::do_creation_processing ();
53 }
54
55 void
56 Staff_performer::do_process_requests ()
57 {
58   String str = new_instrument_str ();
59   if (str.length_i ())
60     {
61       play (new Audio_text (Audio_text::INSTRUMENT_NAME, str));
62       play (new Audio_instrument (str));
63     }
64   Performer_group_performer::do_process_requests ();
65 }
66
67
68 void
69 Staff_performer::do_removal_processing ()
70 {
71   Performer_group_performer::do_removal_processing ();
72   Performer::play (audio_staff_p_);
73   audio_staff_p_ = 0;
74 }
75
76 String 
77 Staff_performer::new_instrument_str () 
78
79   // mustn't ask Score for instrument: it will return piano!
80   String str = get_property ("midi_instrument");
81   if (!str.length_i ())
82     str = get_property ("instrument");
83   if (str == instrument_str_)
84     return "";
85
86   instrument_str_ = str;
87
88   return instrument_str_;
89
90 /* ugh, but can 't
91   if (properties_dict_.elem_b ("instrument"))
92     return properties_dict_["instrument"];
93   return "";
94 */
95 }
96
97 void 
98 Staff_performer::play (Audio_element* p)
99 {
100   if (dynamic_cast<Audio_item *> (p)) 
101     {
102       audio_staff_p_->add_audio_item ( (Audio_item*)p);
103     }
104   Performer::play (p);
105 }
106