From: Heikki Tauriainen Date: Wed, 20 Jul 2016 10:06:56 +0000 (+0300) Subject: Issue 4938 (3/3) Rename Midi_control_function_performer to Midi_control_change_performer X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=23bb09401ef1d8c5f5256b8f7a6c002365b1d88c;p=lilypond.git Issue 4938 (3/3) Rename Midi_control_function_performer to Midi_control_change_performer --- diff --git a/lily/midi-cc-performer.cc b/lily/midi-cc-performer.cc new file mode 100644 index 0000000000..2aff5d0039 --- /dev/null +++ b/lily/midi-cc-performer.cc @@ -0,0 +1,150 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2013--2016 by Heikki Tauriainen . + Adapted from performer implementations + Copyright (C) 1996--2015 Jan Nieuwenhuizen , + Han-Wen Nienhyus and others. + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#include "performer.hh" + +#include "audio-item.hh" +#include "context.hh" +#include "dispatcher.hh" +#include "international.hh" +#include "listener.hh" +#include "midi-cc-announcer.hh" +#include "stream-event.hh" + +#include "translator.icc" + +/** + MIDI control change performer. Announces "set property" events on MIDI + context properties. +*/ +class Midi_control_change_performer : public Performer +{ +public: + TRANSLATOR_DECLARATIONS (Midi_control_change_performer); + void announce_control_change (SCM); + ~Midi_control_change_performer (); + + void connect_to_context (Context *c); + void disconnect_from_context (Context *c); + +private: + class Control_change_announcer : public Midi_control_change_announcer + { + public: + Control_change_announcer (Midi_control_change_performer *p, + Stream_event *ev, const string &s); + + SCM get_property_value (const char *property_name); + void do_announce (Audio_control_change *item); + + private: + Midi_control_change_performer *performer_; + Stream_event *event_; + string symbol_; + }; +}; + +Midi_control_change_performer::Midi_control_change_performer () +{ +} + +Midi_control_change_performer::~Midi_control_change_performer () +{ +} + +void +Midi_control_change_performer::connect_to_context (Context *c) +{ + c->events_below ()-> + add_listener (GET_LISTENER (Midi_control_change_performer, + announce_control_change), + ly_symbol2scm ("SetProperty")); +} + +void +Midi_control_change_performer::disconnect_from_context (Context *c) +{ + c->events_below ()-> + remove_listener (GET_LISTENER (Midi_control_change_performer, + announce_control_change), + ly_symbol2scm ("SetProperty")); +} + +void +Midi_control_change_performer::announce_control_change (SCM sev) +{ + Stream_event *ev = unsmob (sev); + SCM sym = ev->get_property ("symbol"); + if (!scm_is_symbol (sym)) + return; + + Control_change_announcer a (this, ev, ly_symbol2string (sym)); + a.announce_control_changes (); +} + +Midi_control_change_performer::Control_change_announcer::Control_change_announcer +(Midi_control_change_performer *p, Stream_event *ev, const string &s) + : Midi_control_change_announcer (ev->origin ()), + performer_ (p), + event_ (ev), + symbol_ (s) +{ +} + +SCM +Midi_control_change_performer::Control_change_announcer::get_property_value +(const char *property_name) +{ + return symbol_ == property_name ? event_->get_property ("value") : SCM_EOL; +} + +void Midi_control_change_performer::Control_change_announcer::do_announce +(Audio_control_change *item) +{ + performer_->announce_element (Audio_element_info (item, 0)); +} + +void +Midi_control_change_performer::boot () +{ + +} + +ADD_TRANSLATOR (Midi_control_change_performer, + /* doc */ + "This performer listens to SetProperty events on context " + "properties for generating MIDI control changes and " + "prepares them for MIDI output.", + + /* create */ + "", + + /* read */ + "midiBalance " + "midiPanPosition " + "midiExpression " + "midiReverbLevel " + "midiChorusLevel ", + + /* write */ + "" + ); diff --git a/lily/midi-control-function-performer.cc b/lily/midi-control-function-performer.cc deleted file mode 100644 index 48037e9f97..0000000000 --- a/lily/midi-control-function-performer.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - This file is part of LilyPond, the GNU music typesetter. - - Copyright (C) 2013--2016 by Heikki Tauriainen . - Adapted from performer implementations - Copyright (C) 1996--2015 Jan Nieuwenhuizen , - Han-Wen Nienhyus and others. - - LilyPond is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - LilyPond is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LilyPond. If not, see . -*/ - -#include "performer.hh" - -#include "audio-item.hh" -#include "context.hh" -#include "dispatcher.hh" -#include "international.hh" -#include "listener.hh" -#include "midi-cc-announcer.hh" -#include "stream-event.hh" - -#include "translator.icc" - -/** - MIDI control function performer. Announces "set property" events on MIDI - context properties. -*/ -class Midi_control_function_performer : public Performer -{ -public: - TRANSLATOR_DECLARATIONS (Midi_control_function_performer); - void announce_function_value_change (SCM); - ~Midi_control_function_performer (); - - void connect_to_context (Context *c); - void disconnect_from_context (Context *c); - -private: - class Control_change_announcer : public Midi_control_change_announcer - { - public: - Control_change_announcer (Midi_control_function_performer *p, - Stream_event *ev, const string &s); - - SCM get_property_value (const char *property_name); - void do_announce (Audio_control_change *item); - - private: - Midi_control_function_performer *performer_; - Stream_event *event_; - string symbol_; - }; -}; - -Midi_control_function_performer::Midi_control_function_performer () -{ -} - -Midi_control_function_performer::~Midi_control_function_performer () -{ -} - -void -Midi_control_function_performer::connect_to_context (Context *c) -{ - c->events_below ()-> - add_listener (GET_LISTENER (Midi_control_function_performer, - announce_function_value_change), - ly_symbol2scm ("SetProperty")); -} - -void -Midi_control_function_performer::disconnect_from_context (Context *c) -{ - c->events_below ()-> - remove_listener (GET_LISTENER (Midi_control_function_performer, - announce_function_value_change), - ly_symbol2scm ("SetProperty")); -} - -void -Midi_control_function_performer::announce_function_value_change (SCM sev) -{ - Stream_event *ev = unsmob (sev); - SCM sym = ev->get_property ("symbol"); - if (!scm_is_symbol (sym)) - return; - - Control_change_announcer a (this, ev, ly_symbol2string (sym)); - a.announce_control_changes (); -} - -Midi_control_function_performer::Control_change_announcer::Control_change_announcer -(Midi_control_function_performer *p, Stream_event *ev, const string &s) - : Midi_control_change_announcer (ev->origin ()), - performer_ (p), - event_ (ev), - symbol_ (s) -{ -} - -SCM -Midi_control_function_performer::Control_change_announcer::get_property_value -(const char *property_name) -{ - return symbol_ == property_name ? event_->get_property ("value") : SCM_EOL; -} - -void Midi_control_function_performer::Control_change_announcer::do_announce -(Audio_control_change *item) -{ - performer_->announce_element (Audio_element_info (item, 0)); -} - -void -Midi_control_function_performer::boot () -{ - -} - -ADD_TRANSLATOR (Midi_control_function_performer, - /* doc */ - "This performer listens to SetProperty events on context " - "properties for generating MIDI control changes and " - "prepares them for MIDI output.", - - /* create */ - "", - - /* read */ - "midiBalance " - "midiPanPosition " - "midiExpression " - "midiReverbLevel " - "midiChorusLevel ", - - /* write */ - "" - ); diff --git a/ly/performer-init.ly b/ly/performer-init.ly index 00c4bdf3da..644a0bd2d6 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -31,7 +31,7 @@ \consists "Staff_performer" \consists "Key_performer" - \consists "Midi_control_function_performer" + \consists "Midi_control_change_performer" } \context {