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 try_music (Music* req_l);
32 void deprecated_process_music ();
33 virtual void stop_translation_timestep ();
34 virtual void create_grobs ();
38 Audio_dynamic* audio_p_;
41 ADD_THIS_TRANSLATOR (Dynamic_performer);
43 Dynamic_performer::Dynamic_performer ()
49 Dynamic_performer::~Dynamic_performer ()
55 Dynamic_performer::deprecated_process_music ()
59 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
61 SCM svolume = SCM_EOL;
62 if (gh_procedure_p (proc))
65 svolume = gh_call1 (proc, script_req_l_->get_mus_property ("text"));
69 if (gh_number_p (svolume))
70 volume = gh_scm2double (svolume);
73 properties override default equaliser setting
75 SCM min = get_property ("midiMinimumVolume");
76 SCM max = get_property ("midiMaximumVolume");
77 if (gh_number_p (min) || gh_number_p (max))
80 if (gh_number_p (min))
81 iv[MIN] = gh_scm2double (min);
82 if (gh_number_p (max))
83 iv[MAX] = gh_scm2double (max);
84 volume = iv[MIN] + iv.length () * volume;
89 urg, code duplication:: staff_performer
91 SCM s = get_property ("midiInstrument");
94 s = get_property ("instrument");
97 s = ly_str02scm ("piano");
100 SCM eq = get_property ("instrumentEqualizer");
101 if (gh_procedure_p (eq))
103 s = gh_call1 (eq, s);
109 iv[MIN] = gh_scm2double (gh_car (s));
110 iv[MAX] = gh_scm2double (gh_cdr (s));
111 volume = iv[MIN] + iv.length () * volume;
115 audio_p_ = new Audio_dynamic (volume);
116 Audio_element_info info (audio_p_, script_req_l_);
117 announce_element (info);
123 Dynamic_performer::create_grobs ()
125 deprecated_process_music ();
129 Dynamic_performer::stop_translation_timestep ()
133 play_element (audio_p_);
139 Dynamic_performer::try_music (Music* r)
143 if( dynamic_cast <Text_script_req*> (r)
144 && r->get_mus_property ("text-type") == ly_symbol2scm ("dynamic"))