2 dynamic-performer.cc -- implement Dynamic_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
12 #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 (gh_procedure_p (proc
))
52 svolume
= gh_call1 (proc
, script_req_
->get_mus_property ("text"));
56 if (gh_number_p (svolume
))
57 volume
= gh_scm2double (svolume
);
60 properties override default equaliser setting
62 SCM min
= get_property ("midiMinimumVolume");
63 SCM max
= get_property ("midiMaximumVolume");
64 if (gh_number_p (min
) || gh_number_p (max
))
67 if (gh_number_p (min
))
68 iv
[MIN
] = gh_scm2double (min
);
69 if (gh_number_p (max
))
70 iv
[MAX
] = gh_scm2double (max
);
71 volume
= iv
[MIN
] + iv
.length () * volume
;
76 urg, code duplication:: staff_performer
78 SCM s
= get_property ("midiInstrument");
81 s
= get_property ("instrument");
84 s
= scm_makfrom0str ("piano");
87 SCM eq
= get_property ("instrumentEqualizer");
88 if (gh_procedure_p (eq
))
96 iv
[MIN
] = gh_scm2double (ly_car (s
));
97 iv
[MAX
] = gh_scm2double (ly_cdr (s
));
98 volume
= iv
[MIN
] + iv
.length () * volume
;
102 audio_
= new Audio_dynamic (volume
);
103 Audio_element_info
info (audio_
, script_req_
);
104 announce_element (info
);
110 Dynamic_performer::stop_translation_timestep ()
114 play_element (audio_
);
120 Dynamic_performer::try_music (Music
* r
)
124 if (r
->is_mus_type ("absolute-dynamic-event")) // fixme.
133 ENTER_DESCRIPTION(Dynamic_performer
,
136 /* accepts */ "absolute-dynamic-event",
138 /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",