]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff-performer.cc
patch::: 1.3.18.jcn1
[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--1999 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 ADD_THIS_TRANSLATOR (Staff_performer);
17
18 Staff_performer::Staff_performer ()
19 {
20   audio_staff_p_ = 0;
21   instrument_p_ = 0;
22   instrument_name_p_ = 0;
23   name_p_ = 0;
24   tempo_p_ = 0;
25 }
26
27 Staff_performer::~Staff_performer ()
28 {
29 }
30
31 void
32 Staff_performer::do_creation_processing ()
33 {
34   audio_staff_p_ = new Audio_staff;
35   announce_element (Audio_element_info (audio_staff_p_, 0));
36
37   name_p_ = new Audio_text (Audio_text::TRACK_NAME, id_str_);
38   announce_element (Audio_element_info (name_p_, 0));
39
40   tempo_p_ = new Audio_tempo (get_tempo_i ());
41   announce_element (Audio_element_info (tempo_p_, 0));
42
43   Performer_group_performer::do_creation_processing ();
44 }
45
46 void
47 Staff_performer::do_process_requests ()
48 {
49   String str = new_instrument_str ();
50   if (str.length_i ())
51     {
52       instrument_name_p_ = new Audio_text (Audio_text::INSTRUMENT_NAME, str);
53       announce_element (Audio_element_info (instrument_name_p_, 0));
54       instrument_p_ = new Audio_instrument (str);
55       announce_element (Audio_element_info (instrument_p_, 0));
56     }
57   Performer_group_performer::do_process_requests ();
58 }
59
60 void
61 Staff_performer::do_pre_move_processing ()
62 {
63   if (name_p_)
64     {
65       play_element (name_p_);
66       name_p_ = 0;
67     }
68   if (tempo_p_)
69     {
70       play_element (tempo_p_);
71       tempo_p_ = 0;
72     }
73   if (instrument_name_p_)
74     {
75       play_element (instrument_name_p_);
76       instrument_name_p_ = 0;
77     }
78   if (instrument_p_)
79     {
80       play_element (instrument_p_);
81       instrument_p_ = 0;
82     }
83   Performer_group_performer::do_pre_move_processing ();
84 }
85
86 void
87 Staff_performer::do_removal_processing ()
88 {
89   Performer_group_performer::do_removal_processing ();
90   Performer::play_element (audio_staff_p_);
91   audio_staff_p_ = 0;
92 }
93
94 String 
95 Staff_performer::new_instrument_str () 
96
97   // mustn't ask Score for instrument: it will return piano!
98   SCM minstr = get_property (ly_symbol2scm ("midiInstrument"), 0);
99
100   if (!gh_string_p(minstr))
101     minstr = get_property (ly_symbol2scm ("instrument"), 0);
102
103   if (ly_scm2string (minstr) == instrument_str_)
104     return "";
105
106   instrument_str_ = ly_scm2string (minstr);
107
108   return instrument_str_;
109 }
110
111 void 
112 Staff_performer::play_element (Audio_element* p)
113 {
114   if (Audio_item *ai = dynamic_cast<Audio_item *> (p)) 
115     {
116       audio_staff_p_->add_audio_item (ai);
117     }
118   Performer::play_element (p);
119 }
120