2 dynamic-performer.cc -- implement Dynamic_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "audio-item.hh"
15 handle multiple events
17 perform absolute (text) dynamics
19 class Dynamic_performer : public Performer
22 TRANSLATOR_DECLARATIONS (Dynamic_performer);
24 virtual bool try_music (Music *req);
25 virtual void stop_translation_timestep ();
26 virtual void create_audio_elements ();
30 Audio_dynamic *audio_;
33 Dynamic_performer::Dynamic_performer ()
40 Dynamic_performer::create_audio_elements ()
44 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
46 SCM svolume = SCM_EOL;
47 if (ly_c_procedure_p (proc))
50 svolume = scm_call_1 (proc, script_req_->get_property ("text"));
53 Real volume = robust_scm2double (svolume, 0.5);
56 properties override default equaliser setting
58 SCM min = get_property ("midiMinimumVolume");
59 SCM max = get_property ("midiMaximumVolume");
60 if (scm_is_number (min) || scm_is_number (max))
63 if (scm_is_number (min))
64 iv[MIN] = scm_to_double (min);
65 if (scm_is_number (max))
66 iv[MAX] = scm_to_double (max);
67 volume = iv[MIN] + iv.length () * volume;
72 urg, code duplication:: staff_performer
74 SCM s = get_property ("midiInstrument");
76 if (!scm_is_string (s))
77 s = get_property ("instrument");
79 if (!scm_is_string (s))
80 s = scm_makfrom0str ("piano");
82 SCM eq = get_property ("instrumentEqualizer");
83 if (ly_c_procedure_p (eq))
85 s = scm_call_1 (eq, s);
88 if (is_number_pair (s))
90 Interval iv = ly_scm2interval (s);
91 volume = iv[MIN] + iv.length () * volume;
95 audio_ = new Audio_dynamic (volume);
96 Audio_element_info info (audio_, script_req_);
97 announce_element (info);
103 Dynamic_performer::stop_translation_timestep ()
107 play_element (audio_);
113 Dynamic_performer::try_music (Music *r)
117 if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
126 ADD_TRANSLATOR (Dynamic_performer,
129 /* accepts */ "absolute-dynamic-event",
131 /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",