Ardour  8.7-15-gadf511264b
patch_change_widget.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __gtkardour_patch_change_widget_h__
20 #define __gtkardour_patch_change_widget_h__
21 
22 #include <gtkmm/box.h>
23 #include <gtkmm/notebook.h>
24 #include <gtkmm/spinbutton.h>
25 #include <gtkmm/table.h>
26 
27 #include "midi++/midnam_patch.h"
28 #include "pbd/signals.h"
29 
30 #include "ardour/route.h"
31 
32 #include "widgets/ardour_button.h"
34 
35 #include "ardour_dialog.h"
36 #include "ardour_window.h"
37 #include "pianokeyboard.h"
38 
39 namespace ARDOUR {
40  class MIDITrigger;
41 };
42 
44 {
45 public:
47  virtual ~PatchBankList ();
48 
49 protected:
50  void refill (std::shared_ptr<MIDI::Name::ChannelNameSet>, int const bank);
51  void set_active_pgm (uint8_t);
52 
53  virtual void select_bank (uint32_t) = 0;
54  virtual void select_program (uint8_t) = 0;
55  virtual void instrument_info_changed () = 0;
56 
61 
62 private:
64 
66  std::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
68 
69 };
70 
71 class PatchChangeTab : public Gtk::VBox, public PatchBankList
72 {
73 public:
74  PatchChangeTab (int channel);
75 
76  void refresh ();
77  void reset (std::shared_ptr<ARDOUR::Route>, std::shared_ptr<ARDOUR::MIDITrigger>);
78 
79 protected:
80  int bank () const;
81  uint8_t program () const;
82 
83  /* Implement PatchBankList */
84  void select_bank (uint32_t);
85  void select_program (uint8_t);
86 
87 private:
88  void refill_banks ();
90  void enable_toggle ();
93 
95 
96  int _channel;
97  int _bank;
99 
100  std::shared_ptr<ARDOUR::Route> _route;
101  std::shared_ptr<ARDOUR::MIDITrigger> _trigger;
103 };
104 
106 {
107 public:
108  PatchChangeWidget (std::shared_ptr<ARDOUR::Route>);
110 
111  void refresh ();
112 
113 protected:
114  int bank (uint8_t) const;
115  uint8_t program (uint8_t) const;
116 
117  void on_show ();
118  void on_hide ();
119 
120 private:
121  void refill_banks ();
122 
123  void select_channel (uint8_t);
124 
125  /* Implement PatchBankList */
126  void select_bank (uint32_t);
127  void select_program (uint8_t);
128 
129  /* Route Callbacks */
132 
133  /* callbacks from route AC */
134  void bank_changed ();
136  void bankpatch_changed (uint8_t);
137 
138  /* Audition */
140  void check_note_range (bool);
141  void audition ();
143  bool audition_next ();
144 
145  std::shared_ptr<ARDOUR::Route> _route;
147 
148  uint8_t _channel;
150 
153  Gtk::SpinButton _audition_start_spin; // Consider a click-box w/note-names
158 
160 
161  void _note_on_event_handler (int, int);
162  void note_on_event_handler (int, bool for_audition);
164 
165  sigc::connection _note_queue_connection;
168 };
169 
171 {
172 public:
174 
175  void reset (std::shared_ptr<ARDOUR::Route>, std::shared_ptr<ARDOUR::MIDITrigger>);
176  void clear ();
177 
178 private:
179  void on_switch_page (GtkNotebookPage*, guint page_num);
180 
183 
185 };
186 
188 {
189 public:
190  PatchChangeGridDialog (std::shared_ptr<ARDOUR::Route>);
191 
192  void on_hide ()
193  {
194  w.hide ();
196  }
197 
198  void on_show ()
199  {
200  w.show ();
202  }
203 
204  void refresh ()
205  {
206  w.refresh ();
207  }
208 
209 private:
210  void route_property_changed (const PBD::PropertyChange&, std::weak_ptr<ARDOUR::Route>);
213 };
214 
215 #endif
void on_show()
This is a default handler for the signal signal_show().
virtual void on_hide()
This is a default handler for the signal signal_hide().
void refill(std::shared_ptr< MIDI::Name::ChannelNameSet >, int const bank)
ArdourWidgets::ArdourDropdown _bank_select
void select_bank_spin()
Gtk::SpinButton _bank_msb_spin
Gtk::Table _program_table
virtual void instrument_info_changed()=0
Gtk::SpinButton _bank_lsb_spin
ArdourWidgets::ArdourButton _program_btn[128]
virtual void select_program(uint8_t)=0
std::shared_ptr< MIDI::Name::PatchBank > _current_patch_bank
virtual void select_bank(uint32_t)=0
virtual ~PatchBankList()
void set_active_pgm(uint8_t)
PBD::ScopedConnection _route_connection
void route_property_changed(const PBD::PropertyChange &, std::weak_ptr< ARDOUR::Route >)
PatchChangeGridDialog(std::shared_ptr< ARDOUR::Route >)
void on_hide()
This is a default handler for the signal signal_hide().
void on_show()
This is a default handler for the signal signal_show().
std::shared_ptr< ARDOUR::MIDITrigger > _trigger
void instrument_info_changed()
void select_program(uint8_t)
uint8_t program() const
std::shared_ptr< ARDOUR::Route > _route
PatchChangeTab(int channel)
PBD::ScopedConnectionList _connections
int bank() const
void update_sensitivity()
ArdourWidgets::ArdourButton _enable_btn
void select_bank(uint32_t)
void reset(std::shared_ptr< ARDOUR::Route >, std::shared_ptr< ARDOUR::MIDITrigger >)
void refill_banks()
void enable_toggle()
void trigger_property_changed(PBD::PropertyChange const &)
void on_switch_page(GtkNotebookPage *, guint page_num)
void reset(std::shared_ptr< ARDOUR::Route >, std::shared_ptr< ARDOUR::MIDITrigger >)
PBD::ScopedConnection _route_connection
Gtk::SpinButton _audition_velocity
ArdourWidgets::ArdourDropdown _channel_select
std::shared_ptr< ARDOUR::Route > _route
void note_off_event_handler(int)
void processors_changed()
void select_channel(uint8_t)
void on_show()
This is a default handler for the signal signal_show().
void on_hide()
This is a default handler for the signal signal_hide().
ARDOUR::InstrumentInfo & _info
uint8_t program(uint8_t) const
ArdourWidgets::ArdourButton _audition_enable
void select_program(uint8_t)
PBD::ScopedConnectionList _ac_connections
int bank(uint8_t) const
Gtk::SpinButton _audition_start_spin
void note_on_event_handler(int, bool for_audition)
PBD::ScopedConnectionList _route_connections
void select_bank(uint32_t)
void _note_on_event_handler(int, int)
Gtk::SpinButton _audition_end_spin
void check_note_range(bool)
PatchChangeWidget(std::shared_ptr< ARDOUR::Route >)
sigc::connection _note_queue_connection
void instrument_info_changed()
void bankpatch_changed(uint8_t)
struct _GtkNotebookPage GtkNotebookPage
Definition: gtknotebook.h:58