2 dynamic-performer.cc -- implement Dynamic_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "command-request.hh"
11 #include "musical-request.hh"
12 #include "audio-item.hh"
16 handle multiple requests
17 handle span requests (crescendo/decrescendo)
21 perform absolute (text) dynamics
23 class Dynamic_performer : public Performer
26 VIRTUAL_COPY_CONS (Translator);
29 ~Dynamic_performer ();
32 void do_print () const;
33 virtual bool do_try_music (Music* req_l);
34 virtual void do_process_music ();
35 virtual void do_pre_move_processing ();
38 Text_script_req* text_script_req_l_;
39 Audio_dynamic* audio_p_;
42 ADD_THIS_TRANSLATOR (Dynamic_performer);
44 Dynamic_performer::Dynamic_performer ()
46 text_script_req_l_ = 0;
50 Dynamic_performer::~Dynamic_performer ()
55 Dynamic_performer::do_print () const
58 if (text_script_req_l_)
59 text_script_req_l_->print ();
64 Dynamic_performer::do_process_music ()
66 if (text_script_req_l_)
71 (ly_symbol2scm ("dynamic-absolute-volume"),
72 ly_quote_scm (ly_str02scm (text_script_req_l_->text_str_.ch_C ())),
74 Real volume = gh_scm2double (scm_eval (ly_symbol2scm ("dynamic-default-volume")));
76 volume = gh_scm2double (s);
79 properties override default equaliser setting
81 SCM min = get_property ("midiMinimumVolume");
82 SCM max = get_property ("midiMaximumVolume");
83 if (gh_number_p (min) || gh_number_p (max))
86 if (gh_number_p (min))
87 iv[MIN] = gh_scm2double (min);
88 if (gh_number_p (max))
89 iv[MAX] = gh_scm2double (max);
90 volume = iv[MIN] + iv.length () * volume;
95 urg, code duplication:: staff_performer
97 s = get_property ("midiInstrument");
100 s = get_property ("instrument");
103 s = ly_str02scm ("piano");
106 s = scm_eval (gh_list (ly_symbol2scm ("instrument-equaliser"),
111 iv[MIN] = gh_scm2double (gh_car (s));
112 iv[MAX] = gh_scm2double (gh_cdr (s));
113 volume = iv[MIN] + iv.length () * volume;
117 audio_p_ = new Audio_dynamic (volume);
118 Audio_element_info info (audio_p_, text_script_req_l_);
119 announce_element (info);
120 text_script_req_l_ = 0;
125 Dynamic_performer::do_pre_move_processing ()
129 play_element (audio_p_);
135 Dynamic_performer::do_try_music (Music* r)
137 if (!text_script_req_l_)
139 // urg, text script, style `dynamic' is how absolute dynamics appear
140 if(Text_script_req* t = dynamic_cast <Text_script_req*> (r))
142 if (t->style_str_ == "dynamic")
144 text_script_req_l_ = t;