2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __gtkardour_patch_change_widget_h__
20 #define __gtkardour_patch_change_widget_h__
22 #include <gtkmm/box.h>
23 #include <gtkmm/spinbutton.h>
24 #include <gtkmm/table.h>
26 #include "pbd/signals.h"
27 #include "midi++/midnam_patch.h"
29 #include "ardour/route.h"
31 #include "widgets/ardour_button.h"
32 #include "widgets/ardour_dropdown.h"
34 #include "ardour_dialog.h"
35 #include "gtk_pianokeyboard.h"
37 class PatchChangeWidget : public Gtk::VBox
40 PatchChangeWidget (boost::shared_ptr<ARDOUR::Route>);
41 ~PatchChangeWidget ();
46 int bank (uint8_t) const;
47 uint8_t program (uint8_t) const;
53 boost::shared_ptr<ARDOUR::Route> _route;
55 ArdourWidgets::ArdourDropdown _channel_select;
56 ArdourWidgets::ArdourDropdown _bank_select;
57 Gtk::SpinButton _bank_msb_spin;
58 Gtk::SpinButton _bank_lsb_spin;
59 ArdourWidgets::ArdourButton _program_btn[128];
60 Gtk::Table _program_table;
63 bool _ignore_spin_btn_signals;
64 bool _no_notifications;
66 void select_channel (uint8_t);
67 void select_bank (uint32_t);
68 void select_bank_spin ();
69 void select_program (uint8_t);
72 void program_changed ();
73 void bankpatch_changed (uint8_t);
76 void refill_program_list ();
78 void instrument_info_changed ();
79 void processors_changed ();
81 PBD::ScopedConnection _info_changed_connection;
82 PBD::ScopedConnection _route_connection;
83 PBD::ScopedConnectionList _ac_connections;
85 ARDOUR::InstrumentInfo& _info;
86 boost::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
88 void audition_toggle ();
89 void check_note_range (bool);
91 void cancel_audition ();
92 bool audition_next ();
93 sigc::connection _note_queue_connection;
95 ArdourWidgets::ArdourButton _audition_enable;
96 Gtk::SpinButton _audition_start_spin; // Consider a click-box w/note-names
97 Gtk::SpinButton _audition_end_spin;
98 Gtk::SpinButton _audition_velocity;
99 uint8_t _audition_note_num;
100 bool _audition_note_on;
102 PianoKeyboard* _piano;
103 Gtk::Widget* _pianomm;
105 static void _note_on_event_handler (GtkWidget*, int, gpointer);
106 static void _note_off_event_handler (GtkWidget*, int, gpointer);
107 void note_on_event_handler (int, bool for_audition);
108 void note_off_event_handler (int);
111 class PatchChangeGridDialog : public ArdourDialog
114 PatchChangeGridDialog (boost::shared_ptr<ARDOUR::Route>);
115 void on_hide () { w.hide (); ArdourDialog::on_hide (); }
116 void on_show () { w.show (); ArdourDialog::on_show (); }
117 void refresh () { w.refresh (); }
120 void route_property_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Route>);
121 PBD::ScopedConnection _route_connection;