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"
13 #include "translator.icc"
19 handle multiple events
21 perform absolute (text) dynamics
23 class Dynamic_performer : public Performer
26 TRANSLATOR_DECLARATIONS (Dynamic_performer);
28 virtual bool try_music (Music *event);
29 void stop_translation_timestep ();
30 virtual void create_audio_elements ();
34 Audio_dynamic *audio_;
37 Dynamic_performer::Dynamic_performer ()
44 Dynamic_performer::create_audio_elements ()
48 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
50 SCM svolume = SCM_EOL;
51 if (ly_is_procedure (proc))
54 svolume = scm_call_1 (proc, script_event_->get_property ("text"));
57 Real volume = robust_scm2double (svolume, 0.5);
60 properties override default equaliser setting
62 SCM min = get_property ("midiMinimumVolume");
63 SCM max = get_property ("midiMaximumVolume");
64 if (scm_is_number (min) || scm_is_number (max))
67 if (scm_is_number (min))
68 iv[MIN] = scm_to_double (min);
69 if (scm_is_number (max))
70 iv[MAX] = scm_to_double (max);
71 volume = iv[MIN] + iv.length () * volume;
76 urg, code duplication:: staff_performer
78 SCM s = get_property ("midiInstrument");
80 if (!scm_is_string (s))
81 s = get_property ("instrument");
83 if (!scm_is_string (s))
84 s = scm_makfrom0str ("piano");
86 SCM eq = get_property ("instrumentEqualizer");
87 if (ly_is_procedure (eq))
89 s = scm_call_1 (eq, s);
92 if (is_number_pair (s))
94 Interval iv = ly_scm2interval (s);
95 volume = iv[MIN] + iv.length () * volume;
99 audio_ = new Audio_dynamic (volume);
100 Audio_element_info info (audio_, script_event_);
101 announce_element (info);
107 Dynamic_performer::stop_translation_timestep ()
111 play_element (audio_);
117 Dynamic_performer::try_music (Music *r)
121 if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
130 ADD_TRANSLATOR (Dynamic_performer,
133 /* accepts */ "absolute-dynamic-event",
134 /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",