2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2013--2016 by Heikki Tauriainen <g034737@welho.com>.
5 Adapted from performer implementations
6 Copyright (C) 1996--2015 Jan Nieuwenhuizen <janneke@gnu.org>,
7 Han-Wen Nienhyus <hanwen@xs4all.nl> and others.
9 LilyPond is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 LilyPond is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
23 #include "performer.hh"
25 #include "audio-item.hh"
27 #include "dispatcher.hh"
28 #include "international.hh"
29 #include "listener.hh"
30 #include "midi-cc-announcer.hh"
31 #include "stream-event.hh"
33 #include "translator.icc"
36 MIDI control change performer. Announces "set property" events on MIDI
39 class Midi_control_change_performer : public Performer
42 TRANSLATOR_DECLARATIONS (Midi_control_change_performer);
43 void announce_control_change (SCM);
44 ~Midi_control_change_performer ();
46 void connect_to_context (Context *c);
47 void disconnect_from_context (Context *c);
50 class Control_change_announcer : public Midi_control_change_announcer
53 Control_change_announcer (Midi_control_change_performer *p,
54 Stream_event *ev, const string &s);
56 SCM get_property_value (const char *property_name);
57 void do_announce (Audio_control_change *item);
60 Midi_control_change_performer *performer_;
66 Midi_control_change_performer::Midi_control_change_performer (Context *c)
71 Midi_control_change_performer::~Midi_control_change_performer ()
76 Midi_control_change_performer::connect_to_context (Context *c)
79 add_listener (GET_LISTENER (Midi_control_change_performer,
80 announce_control_change),
81 ly_symbol2scm ("SetProperty"));
85 Midi_control_change_performer::disconnect_from_context (Context *c)
88 remove_listener (GET_LISTENER (Midi_control_change_performer,
89 announce_control_change),
90 ly_symbol2scm ("SetProperty"));
94 Midi_control_change_performer::announce_control_change (SCM sev)
96 Stream_event *ev = unsmob<Stream_event> (sev);
97 SCM sym = ev->get_property ("symbol");
98 if (!scm_is_symbol (sym))
101 Control_change_announcer a (this, ev, ly_symbol2string (sym));
102 a.announce_control_changes ();
105 Midi_control_change_performer::Control_change_announcer::Control_change_announcer
106 (Midi_control_change_performer *p, Stream_event *ev, const string &s)
107 : Midi_control_change_announcer (ev->origin ()),
115 Midi_control_change_performer::Control_change_announcer::get_property_value
116 (const char *property_name)
118 return symbol_ == property_name ? event_->get_property ("value") : SCM_EOL;
121 void Midi_control_change_performer::Control_change_announcer::do_announce
122 (Audio_control_change *item)
124 performer_->announce_element (Audio_element_info (item, 0));
128 Midi_control_change_performer::boot ()
133 ADD_TRANSLATOR (Midi_control_change_performer,
135 "This performer listens to SetProperty events on context "
136 "properties for generating MIDI control changes and "
137 "prepares them for MIDI output.",