Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <gtkmm/box.h>
22 #include <gtkmm/notebook.h>
23 #include <gtkmm/spinbutton.h>
24 #include <gtkmm/table.h>
25 
26 #include "midi++/midnam_patch.h"
27 #include "pbd/signals.h"
28 
29 #include "ardour/route.h"
30 
31 #include "widgets/ardour_button.h"
33 
34 #include "ardour_dialog.h"
35 #include "ardour_window.h"
36 #include "pianokeyboard.h"
37 
38 namespace ARDOUR {
39  class MIDITrigger;
40 };
41 
43 {
44 public:
46  virtual ~PatchBankList ();
47 
48 protected:
49  void refill (std::shared_ptr<MIDI::Name::ChannelNameSet>, int const bank);
50  void set_active_pgm (uint8_t);
51 
52  virtual void select_bank (uint32_t) = 0;
53  virtual void select_program (uint8_t) = 0;
54  virtual void instrument_info_changed () = 0;
55 
60 
61 private:
63 
65  std::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
67 
68 };
69 
70 class PatchChangeTab : public Gtk::VBox, public PatchBankList
71 {
72 public:
73  PatchChangeTab (int channel);
74 
75  void refresh ();
76  void reset (std::shared_ptr<ARDOUR::Route>, std::shared_ptr<ARDOUR::MIDITrigger>);
77 
78 protected:
79  int bank () const;
80  uint8_t program () const;
81 
82  /* Implement PatchBankList */
83  void select_bank (uint32_t);
84  void select_program (uint8_t);
85 
86 private:
87  void refill_banks ();
89  void enable_toggle ();
92 
94 
95  int _channel;
96  int _bank;
98 
99  std::shared_ptr<ARDOUR::Route> _route;
100  std::shared_ptr<ARDOUR::MIDITrigger> _trigger;
102 };
103 
105 {
106 public:
107  PatchChangeWidget (std::shared_ptr<ARDOUR::Route>);
109 
110  void refresh ();
111 
112 protected:
113  int bank (uint8_t) const;
114  uint8_t program (uint8_t) const;
115 
116  void on_show ();
117  void on_hide ();
118 
119 private:
120  void refill_banks ();
121 
122  void select_channel (uint8_t);
123 
124  /* Implement PatchBankList */
125  void select_bank (uint32_t);
126  void select_program (uint8_t);
127 
128  /* Route Callbacks */
131 
132  /* callbacks from route AC */
133  void bank_changed ();
135  void bankpatch_changed (uint8_t);
136 
137  /* Audition */
139  void check_note_range (bool);
140  void audition ();
142  bool audition_next ();
143 
144  std::shared_ptr<ARDOUR::Route> _route;
146 
147  uint8_t _channel;
149 
152  Gtk::SpinButton _audition_start_spin; // Consider a click-box w/note-names
157 
159 
160  void _note_on_event_handler (int, int);
161  void note_on_event_handler (int, bool for_audition);
163 
164  sigc::connection _note_queue_connection;
167 };
168 
170 {
171 public:
173 
174  void reset (std::shared_ptr<ARDOUR::Route>, std::shared_ptr<ARDOUR::MIDITrigger>);
175  void clear ();
176 
177 private:
178  void on_switch_page (GtkNotebookPage*, guint page_num);
179 
182 
184 };
185 
187 {
188 public:
189  PatchChangeGridDialog (std::shared_ptr<ARDOUR::Route>);
190 
191  void on_hide ()
192  {
193  w.hide ();
195  }
196 
197  void on_show ()
198  {
199  w.show ();
201  }
202 
203  void refresh ()
204  {
205  w.refresh ();
206  }
207 
208 private:
209  void route_property_changed (const PBD::PropertyChange&, std::weak_ptr<ARDOUR::Route>);
212 };
213 
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