X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdynamic-performer.cc;h=f6885b554b94f63338043adb6d7f7d47f0093fbe;hb=f0968255554403de5d86b7e6efff5e644cba7f7a;hp=552a76982645fd1a89a3086e02da4496cec131a1;hpb=df4a7c4a55148e065d878dcc2f7e09ac27ea9c32;p=lilypond.git diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index 552a769826..f6885b554b 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -3,84 +3,67 @@ source file of the GNU LilyPond music typesetter - (c) 2000 Jan Nieuwenhuizen + (c) 2000--2004 Jan Nieuwenhuizen */ #include "performer.hh" -#include "command-request.hh" -#include "musical-request.hh" #include "audio-item.hh" /* TODO: - handle multiple requests - */ + + handle multiple events -/** - perform absolute (text) dynamics + perform absolute (text) dynamics */ class Dynamic_performer : public Performer { public: - VIRTUAL_COPY_CONS (Translator); - - Dynamic_performer (); - ~Dynamic_performer (); - + TRANSLATOR_DECLARATIONS (Dynamic_performer); protected: - virtual bool try_music (Music* req_l); - void deprecated_process_music (); + virtual bool try_music (Music* req); virtual void stop_translation_timestep (); - virtual void create_grobs (); + virtual void create_audio_elements (); private: - Music* script_req_l_; - Audio_dynamic* audio_p_; + Music* script_req_; + Audio_dynamic* audio_; }; -ADD_THIS_TRANSLATOR (Dynamic_performer); - Dynamic_performer::Dynamic_performer () { - script_req_l_ = 0; - audio_p_ = 0; + script_req_ = 0; + audio_ = 0; } -Dynamic_performer::~Dynamic_performer () -{ -} - - void -Dynamic_performer::deprecated_process_music () +Dynamic_performer::create_audio_elements () { - if (script_req_l_) + if (script_req_) { SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); SCM svolume = SCM_EOL; - if (gh_procedure_p (proc)) + if (ly_c_procedure_p (proc)) { // urg - svolume = gh_call1 (proc, script_req_l_->get_mus_property ("text")); + svolume = scm_call_1 (proc, script_req_->get_property ("text")); } - Real volume = 0.5; - if (gh_number_p (svolume)) - volume = gh_scm2double (svolume); + Real volume = robust_scm2double (svolume, 0.5); /* properties override default equaliser setting */ SCM min = get_property ("midiMinimumVolume"); SCM max = get_property ("midiMaximumVolume"); - if (gh_number_p (min) || gh_number_p (max)) + if (scm_is_number (min) || scm_is_number (max)) { Interval iv (0, 1); - if (gh_number_p (min)) - iv[MIN] = gh_scm2double (min); - if (gh_number_p (max)) - iv[MAX] = gh_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 @@ -90,63 +73,61 @@ Dynamic_performer::deprecated_process_music () */ SCM s = get_property ("midiInstrument"); - if (!gh_string_p(s)) + if (!scm_is_string (s)) s = get_property ("instrument"); - if (!gh_string_p(s)) - s = ly_str02scm ("piano"); + if (!scm_is_string (s)) + s = scm_makfrom0str ("piano"); SCM eq = get_property ("instrumentEqualizer"); - if (gh_procedure_p (eq)) + if (ly_c_procedure_p (eq)) { - s = gh_call1 (eq, s); + s = scm_call_1 (eq, s); } - if (gh_pair_p (s)) + if (is_number_pair (s)) { - Interval iv; - iv[MIN] = gh_scm2double (gh_car (s)); - iv[MAX] = gh_scm2double (gh_cdr (s)); + Interval iv = ly_scm2interval (s); volume = iv[MIN] + iv.length () * volume; } } - audio_p_ = new Audio_dynamic (volume); - Audio_element_info info (audio_p_, script_req_l_); + audio_ = new Audio_dynamic (volume); + Audio_element_info info (audio_, script_req_); announce_element (info); - script_req_l_ = 0; + script_req_ = 0; } } -void -Dynamic_performer::create_grobs () -{ - deprecated_process_music (); -} - void Dynamic_performer::stop_translation_timestep () { - if (audio_p_) + if (audio_) { - play_element (audio_p_); - audio_p_ = 0; + play_element (audio_); + audio_ = 0; } } bool Dynamic_performer::try_music (Music* r) { - if (!script_req_l_) + if (!script_req_) { - if( dynamic_cast (r) - && r->get_mus_property ("text-type") == ly_symbol2scm ("dynamic")) + if (r->is_mus_type ("absolute-dynamic-event")) // fixme. { - script_req_l_ = r; + script_req_ = r; return true; } } return false; } +ADD_TRANSLATOR (Dynamic_performer, + /*descr*/ "", + /* creats*/ "", + /* accepts */ "absolute-dynamic-event", + /* acks */ "", + /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer", + /*writes*/"");