2 dynamic-performer.cc -- implement Dynamic_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
11 #include "audio-item.hh"
13 #include "translator.icc"
18 handle multiple events
20 perform absolute (text) dynamics
22 class Dynamic_performer : public Performer
25 TRANSLATOR_DECLARATIONS (Dynamic_performer);
27 virtual bool try_music (Music *event);
28 void stop_translation_timestep ();
29 void process_music ();
33 Audio_dynamic *audio_;
36 Dynamic_performer::Dynamic_performer ()
43 Dynamic_performer::process_music ()
47 SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
49 SCM svolume = SCM_EOL;
50 if (ly_is_procedure (proc))
53 svolume = scm_call_1 (proc, script_event_->get_property ("text"));
56 Real volume = robust_scm2double (svolume, 0.5);
59 properties override default equaliser setting
61 SCM min = get_property ("midiMinimumVolume");
62 SCM max = get_property ("midiMaximumVolume");
63 if (scm_is_number (min) || scm_is_number (max))
66 if (scm_is_number (min))
67 iv[MIN] = scm_to_double (min);
68 if (scm_is_number (max))
69 iv[MAX] = scm_to_double (max);
70 volume = iv[MIN] + iv.length () * volume;
75 urg, code duplication:: staff_performer
77 SCM s = get_property ("midiInstrument");
79 if (!scm_is_string (s))
80 s = get_property ("instrument");
82 if (!scm_is_string (s))
83 s = scm_makfrom0str ("piano");
85 SCM eq = get_property ("instrumentEqualizer");
86 if (ly_is_procedure (eq))
87 s = scm_call_1 (eq, s);
89 if (is_number_pair (s))
91 Interval iv = ly_scm2interval (s);
92 volume = iv[MIN] + iv.length () * volume;
96 audio_ = new Audio_dynamic (volume);
97 Audio_element_info info (audio_, script_event_);
98 announce_element (info);
104 Dynamic_performer::stop_translation_timestep ()
108 play_element (audio_);
114 Dynamic_performer::try_music (Music *r)
118 if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
127 ADD_TRANSLATOR (Dynamic_performer,
130 /* accept */ "absolute-dynamic-event",
131 /* read */ "dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",