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
20 perform absolute (text) dynamics
22 class Dynamic_performer : public Performer
25 VIRTUAL_COPY_CONS (Translator);
28 ~Dynamic_performer ();
31 virtual bool do_try_music (Music* req_l);
32 virtual void do_process_music ();
33 virtual void do_pre_move_processing ();
36 Text_script_req* text_script_req_l_;
37 Audio_dynamic* audio_p_;
40 ADD_THIS_TRANSLATOR (Dynamic_performer);
42 Dynamic_performer::Dynamic_performer ()
44 text_script_req_l_ = 0;
48 Dynamic_performer::~Dynamic_performer ()
54 Dynamic_performer::do_process_music ()
56 if (text_script_req_l_)
58 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
60 SCM svolume = SCM_EOL;
61 if (gh_procedure_p (proc))
63 svolume = gh_call1 (proc, ly_str02scm (text_script_req_l_->text_str_.ch_C ()));
67 if (gh_number_p (svolume))
68 volume = gh_scm2double (svolume);
71 properties override default equaliser setting
73 SCM min = get_property ("midiMinimumVolume");
74 SCM max = get_property ("midiMaximumVolume");
75 if (gh_number_p (min) || gh_number_p (max))
78 if (gh_number_p (min))
79 iv[MIN] = gh_scm2double (min);
80 if (gh_number_p (max))
81 iv[MAX] = gh_scm2double (max);
82 volume = iv[MIN] + iv.length () * volume;
87 urg, code duplication:: staff_performer
89 SCM s = get_property ("midiInstrument");
92 s = get_property ("instrument");
95 s = ly_str02scm ("piano");
98 SCM eq = get_property ("instrumentEqualizer");
99 if (gh_procedure_p (eq))
101 s = gh_call1 (eq, s);
107 iv[MIN] = gh_scm2double (gh_car (s));
108 iv[MAX] = gh_scm2double (gh_cdr (s));
109 volume = iv[MIN] + iv.length () * volume;
113 audio_p_ = new Audio_dynamic (volume);
114 Audio_element_info info (audio_p_, text_script_req_l_);
115 announce_element (info);
116 text_script_req_l_ = 0;
121 Dynamic_performer::do_pre_move_processing ()
125 play_element (audio_p_);
131 Dynamic_performer::do_try_music (Music* r)
133 if (!text_script_req_l_)
135 // urg, text script, style `dynamic' is how absolute dynamics appear
136 if(Text_script_req* t = dynamic_cast <Text_script_req*> (r))
138 if (t->style_str_ == "dynamic")
140 text_script_req_l_ = t;