X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdynamic-performer.cc;h=05969cffad6fa28294388ea86afa820a2e225147;hb=18c39bfee02951055e27f737a11525062033503d;hp=4505dbd024a1ce15e785b2a7da9d57235ea42f4d;hpb=94a1966c72301b8bd1d8bb3b8628c3f089d007cf;p=lilypond.git diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 4505dbd024..05969cffad 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -3,69 +3,70 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2004 Jan Nieuwenhuizen + (c) 2000--2006 Jan Nieuwenhuizen */ #include "performer.hh" -#include "event.hh" #include "audio-item.hh" +#include "music.hh" +#include "translator.icc" /* TODO: - - handle multiple events - perform absolute (text) dynamics - */ + handle multiple events + + perform absolute (text) dynamics +*/ class Dynamic_performer : public Performer { public: TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: - virtual bool try_music (Music* req); - virtual void stop_translation_timestep (); - virtual void create_audio_elements (); + virtual bool try_music (Music *event); + void stop_translation_timestep (); + void process_music (); private: - Music* script_req_; - Audio_dynamic* audio_; + Music *script_event_; + Audio_dynamic *audio_; }; Dynamic_performer::Dynamic_performer () { - script_req_ = 0; + script_event_ = 0; audio_ = 0; } void -Dynamic_performer::create_audio_elements () +Dynamic_performer::process_music () { - if (script_req_) + if (script_event_) { SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); - SCM svolume = SCM_EOL; - if (ly_procedure_p (proc)) + SCM svolume = SCM_EOL; + if (ly_is_procedure (proc)) { // urg - svolume = scm_call_1 (proc, script_req_->get_property ("text")); + svolume = scm_call_1 (proc, script_event_->get_property ("text")); } - Real volume = robust_scm2double (svolume, 0.5); + Real volume = robust_scm2double (svolume, 0.5); /* properties override default equaliser setting - */ + */ SCM min = get_property ("midiMinimumVolume"); SCM max = get_property ("midiMaximumVolume"); - if (ly_number_p (min) || ly_number_p (max)) + if (scm_is_number (min) || scm_is_number (max)) { Interval iv (0, 1); - if (ly_number_p (min)) - iv[MIN] = ly_scm2double (min); - if (ly_number_p (max)) - iv[MAX] = ly_scm2double (max); + if (scm_is_number (min)) + iv[MIN] = scm_to_double (min); + if (scm_is_number (max)) + iv[MAX] = scm_to_double (max); volume = iv[MIN] + iv.length () * volume; } else @@ -74,19 +75,16 @@ Dynamic_performer::create_audio_elements () urg, code duplication:: staff_performer */ SCM s = get_property ("midiInstrument"); - - if (!ly_string_p (s)) + + if (!scm_is_string (s)) s = get_property ("instrument"); - - if (!ly_string_p (s)) + + if (!scm_is_string (s)) s = scm_makfrom0str ("piano"); - - + SCM eq = get_property ("instrumentEqualizer"); - if (ly_procedure_p (eq)) - { - s = scm_call_1 (eq, s); - } + if (ly_is_procedure (eq)) + s = scm_call_1 (eq, s); if (is_number_pair (s)) { @@ -94,11 +92,11 @@ Dynamic_performer::create_audio_elements () volume = iv[MIN] + iv.length () * volume; } } - + audio_ = new Audio_dynamic (volume); - Audio_element_info info (audio_, script_req_); + Audio_element_info info (audio_, script_event_); announce_element (info); - script_req_ = 0; + script_event_ = 0; } } @@ -113,23 +111,22 @@ Dynamic_performer::stop_translation_timestep () } bool -Dynamic_performer::try_music (Music* r) +Dynamic_performer::try_music (Music *r) { - if (!script_req_) + if (!script_event_) { if (r->is_mus_type ("absolute-dynamic-event")) // fixme. { - script_req_ = r; + script_event_ = r; return true; } } return false; } -ENTER_DESCRIPTION (Dynamic_performer, - /*descr*/ "", - /* creats*/ "", - /* accepts */ "absolute-dynamic-event", - /* acks */ "", - /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer", - /*writes*/""); +ADD_TRANSLATOR (Dynamic_performer, + /* doc */ "", + /* create */ "", + /* accept */ "absolute-dynamic-event", + /* read */ "dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer", + /*writes*/"");