2 Copyright (C) 2014 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __libardour_midi_scene_changer_h__
21 #define __libardour_midi_scene_changer_h__
23 #include <glibmm/threads.h>
25 #include "ardour/scene_changer.h"
30 class MIDISceneChange;
32 class MIDISceneChanger : public SceneChanger
35 MIDISceneChanger (Session&);
38 void run (framepos_t start, framepos_t end);
39 void set_input_port (boost::shared_ptr<MidiPort>);
40 void set_output_port (boost::shared_ptr<MidiPort>);
42 uint8_t bank_at (framepos_t, uint8_t channel);
43 uint8_t program_at (framepos_t, uint8_t channel);
45 void set_recording (bool);
46 void locate (framepos_t);
48 /** Signal emitted whenever any relevant MIDI input is detected.
50 PBD::Signal0<void> MIDIInputActivity;
52 /** Signal emitted whenever any relevant MIDI output is sent.
54 PBD::Signal0<void> MIDIOutputActivity;
57 typedef std::multimap<framepos_t,boost::shared_ptr<MIDISceneChange> > Scenes;
59 boost::shared_ptr<MidiPort> input_port;
60 boost::shared_ptr<MidiPort> output_port;
61 Glib::Threads::RWLock scene_lock;
64 bool have_seen_bank_changes;
65 framepos_t last_program_message_time;
66 unsigned short current_bank;
67 int last_delivered_program;
68 int last_delivered_bank;
70 void gather (const Locations::LocationList&);
71 bool recording () const;
72 void jump_to (int bank, int program);
73 void rt_deliver (MidiBuffer&, framepos_t, boost::shared_ptr<MIDISceneChange>);
74 void non_rt_deliver (boost::shared_ptr<MIDISceneChange>);
76 void bank_change_input (MIDI::Parser&, unsigned short, int channel);
77 void program_change_input (MIDI::Parser&, MIDI::byte, int channel);
78 void locations_changed ();
80 PBD::ScopedConnectionList incoming_connections;
85 #endif /* __libardour_midi_scene_changer_h__ */