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"
28 #include "ardour/route.h"
30 #include "widgets/ardour_button.h"
31 #include "widgets/ardour_dropdown.h"
33 #include "ardour_dialog.h"
34 #include "gtk_pianokeyboard.h"
36 class PatchChangeWidget : public Gtk::VBox
39 PatchChangeWidget (boost::shared_ptr<ARDOUR::Route>);
40 ~PatchChangeWidget ();
43 int bank (uint8_t) const;
44 uint8_t program (uint8_t) const;
50 boost::shared_ptr<ARDOUR::Route> _route;
52 ArdourWidgets::ArdourDropdown _channel_select;
53 ArdourWidgets::ArdourDropdown _bank_select;
54 Gtk::SpinButton _bank_msb_spin;
55 Gtk::SpinButton _bank_lsb_spin;
56 ArdourWidgets::ArdourButton _program_btn[128];
57 Gtk::Table _program_table;
60 bool _ignore_spin_btn_signals;
62 void select_channel (uint8_t);
63 void select_bank (uint32_t);
64 void select_bank_spin ();
65 void select_program (uint8_t);
68 void program_changed ();
71 void refill_program_list ();
73 void instrument_info_changed ();
75 PBD::ScopedConnection _info_changed_connection;
76 PBD::ScopedConnection _route_connection;
77 PBD::ScopedConnectionList _ac_connections;
79 ARDOUR::InstrumentInfo& _info;
80 boost::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
82 void audition_toggle ();
83 void check_note_range (bool);
85 void cancel_audition ();
86 bool audition_next ();
87 sigc::connection _note_queue_connection;
89 ArdourWidgets::ArdourButton _audition_enable;
90 Gtk::SpinButton _audition_start_spin; // Consider a click-box w/note-names
91 Gtk::SpinButton _audition_end_spin;
92 Gtk::SpinButton _audition_velocity;
93 uint8_t _audition_note_num;
94 bool _audition_note_on;
96 PianoKeyboard* _piano;
97 Gtk::Widget* _pianomm;
99 static void _note_on_event_handler (GtkWidget*, int, gpointer);
100 static void _note_off_event_handler (GtkWidget*, int, gpointer);
101 void note_on_event_handler (int);
102 void note_off_event_handler (int);
105 class PatchChangeGridDialog : public ArdourDialog
108 PatchChangeGridDialog (std::string const&, boost::shared_ptr<ARDOUR::Route>);
109 void on_hide () { w.hide (); ArdourDialog::on_hide (); }
110 void on_show () { w.show (); ArdourDialog::on_show (); }