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 VIRTUAL_COPY_CONS (Translator
);
30 virtual bool try_music (Music
* req_l
);
31 virtual void stop_translation_timestep ();
32 virtual void create_audio_elements ();
36 Audio_dynamic
* audio_p_
;
39 ADD_THIS_TRANSLATOR (Dynamic_performer
);
41 Dynamic_performer::Dynamic_performer ()
48 Dynamic_performer::create_audio_elements ()
52 SCM proc
= get_property ("dynamicAbsoluteVolumeFunction");
54 SCM svolume
= SCM_EOL
;
55 if (gh_procedure_p (proc
))
58 svolume
= gh_call1 (proc
, script_req_l_
->get_mus_property ("text"));
62 if (gh_number_p (svolume
))
63 volume
= gh_scm2double (svolume
);
66 properties override default equaliser setting
68 SCM min
= get_property ("midiMinimumVolume");
69 SCM max
= get_property ("midiMaximumVolume");
70 if (gh_number_p (min
) || gh_number_p (max
))
73 if (gh_number_p (min
))
74 iv
[MIN
] = gh_scm2double (min
);
75 if (gh_number_p (max
))
76 iv
[MAX
] = gh_scm2double (max
);
77 volume
= iv
[MIN
] + iv
.length () * volume
;
82 urg, code duplication:: staff_performer
84 SCM s
= get_property ("midiInstrument");
87 s
= get_property ("instrument");
90 s
= ly_str02scm ("piano");
93 SCM eq
= get_property ("instrumentEqualizer");
94 if (gh_procedure_p (eq
))
102 iv
[MIN
] = gh_scm2double (gh_car (s
));
103 iv
[MAX
] = gh_scm2double (gh_cdr (s
));
104 volume
= iv
[MIN
] + iv
.length () * volume
;
108 audio_p_
= new Audio_dynamic (volume
);
109 Audio_element_info
info (audio_p_
, script_req_l_
);
110 announce_element (info
);
116 Dynamic_performer::stop_translation_timestep ()
120 play_element (audio_p_
);
126 Dynamic_performer::try_music (Music
* r
)
130 if (dynamic_cast <Text_script_req
*> (r
)
131 && r
->get_mus_property ("text-type") == ly_symbol2scm ("dynamic"))