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"
11 #include "audio-item.hh"
17 handle multiple events
19 perform absolute (text) dynamics
21 class Dynamic_performer : public Performer
24 TRANSLATOR_DECLARATIONS (Dynamic_performer);
26 virtual bool try_music (Music *req);
27 virtual void stop_translation_timestep ();
28 virtual void create_audio_elements ();
32 Audio_dynamic *audio_;
35 Dynamic_performer::Dynamic_performer ()
42 Dynamic_performer::create_audio_elements ()
46 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
48 SCM svolume = SCM_EOL;
49 if (ly_is_procedure (proc))
52 svolume = scm_call_1 (proc, script_req_->get_property ("text"));
55 Real volume = robust_scm2double (svolume, 0.5);
58 properties override default equaliser setting
60 SCM min = get_property ("midiMinimumVolume");
61 SCM max = get_property ("midiMaximumVolume");
62 if (scm_is_number (min) || scm_is_number (max))
65 if (scm_is_number (min))
66 iv[MIN] = scm_to_double (min);
67 if (scm_is_number (max))
68 iv[MAX] = scm_to_double (max);
69 volume = iv[MIN] + iv.length () * volume;
74 urg, code duplication:: staff_performer
76 SCM s = get_property ("midiInstrument");
78 if (!scm_is_string (s))
79 s = get_property ("instrument");
81 if (!scm_is_string (s))
82 s = scm_makfrom0str ("piano");
84 SCM eq = get_property ("instrumentEqualizer");
85 if (ly_is_procedure (eq))
87 s = scm_call_1 (eq, s);
90 if (is_number_pair (s))
92 Interval iv = ly_scm2interval (s);
93 volume = iv[MIN] + iv.length () * volume;
97 audio_ = new Audio_dynamic (volume);
98 Audio_element_info info (audio_, script_req_);
99 announce_element (info);
105 Dynamic_performer::stop_translation_timestep ()
109 play_element (audio_);
115 Dynamic_performer::try_music (Music *r)
119 if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
128 ADD_TRANSLATOR (Dynamic_performer,
131 /* accepts */ "absolute-dynamic-event",
133 /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",