2 dynamic-performer.cc -- implement Dynamic_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "command-request.hh"
11 #include "musical-request.hh"
12 #include "audio-item.hh"
16 handle multiple requests
20 perform absolute (text) dynamics
22 class Dynamic_performer
: public Performer
25 TRANSLATOR_DECLARATIONS(Dynamic_performer
);
27 virtual bool try_music (Music
* req
);
28 virtual void stop_translation_timestep ();
29 virtual void create_audio_elements ();
33 Audio_dynamic
* audio_
;
38 Dynamic_performer::Dynamic_performer ()
45 Dynamic_performer::create_audio_elements ()
49 SCM proc
= get_property ("dynamicAbsoluteVolumeFunction");
51 SCM svolume
= SCM_EOL
;
52 if (gh_procedure_p (proc
))
55 svolume
= gh_call1 (proc
, script_req_
->get_mus_property ("text"));
59 if (gh_number_p (svolume
))
60 volume
= gh_scm2double (svolume
);
63 properties override default equaliser setting
65 SCM min
= get_property ("midiMinimumVolume");
66 SCM max
= get_property ("midiMaximumVolume");
67 if (gh_number_p (min
) || gh_number_p (max
))
70 if (gh_number_p (min
))
71 iv
[MIN
] = gh_scm2double (min
);
72 if (gh_number_p (max
))
73 iv
[MAX
] = gh_scm2double (max
);
74 volume
= iv
[MIN
] + iv
.length () * volume
;
79 urg, code duplication:: staff_performer
81 SCM s
= get_property ("midiInstrument");
84 s
= get_property ("instrument");
87 s
= scm_makfrom0str ("piano");
90 SCM eq
= get_property ("instrumentEqualizer");
91 if (gh_procedure_p (eq
))
99 iv
[MIN
] = gh_scm2double (ly_car (s
));
100 iv
[MAX
] = gh_scm2double (ly_cdr (s
));
101 volume
= iv
[MIN
] + iv
.length () * volume
;
105 audio_
= new Audio_dynamic (volume
);
106 Audio_element_info
info (audio_
, script_req_
);
107 announce_element (info
);
113 Dynamic_performer::stop_translation_timestep ()
117 play_element (audio_
);
123 Dynamic_performer::try_music (Music
* r
)
127 if (dynamic_cast <Text_script_req
*> (r
)
128 && r
->get_mus_property ("text-type") == ly_symbol2scm ("dynamic"))
137 ENTER_DESCRIPTION(Dynamic_performer
,
138 "","","","dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer","");