2 Copyright (C) 2010 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 __gtk2_ardour_engine_dialog_h__
21 #define __gtk2_ardour_engine_dialog_h__
27 #include <gtkmm/checkbutton.h>
28 #include <gtkmm/spinbutton.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/expander.h>
32 #include <gtkmm/box.h>
33 #include <gtkmm/buttonbox.h>
34 #include <gtkmm/button.h>
36 #include "pbd/signals.h"
38 #include "ardour_dialog.h"
39 #include "ardour_button.h"
41 class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
46 static bool need_setup ();
48 XMLNode& get_state ();
49 void set_state (const XMLNode&);
51 void set_desired_sample_rate (uint32_t);
54 Gtk::Notebook notebook;
56 /* core fields used by all backends */
58 Gtk::Table basic_packer;
62 Gtk::ComboBoxText backend_combo;
63 Gtk::ComboBoxText driver_combo;
64 Gtk::ComboBoxText device_combo;
65 Gtk::ComboBoxText sample_rate_combo;
66 Gtk::ComboBoxText midi_option_combo;
67 Gtk::ComboBoxText buffer_size_combo;
68 Gtk::Label buffer_size_duration_label;
69 Gtk::Adjustment input_latency_adjustment;
70 Gtk::SpinButton input_latency;
71 Gtk::Adjustment output_latency_adjustment;
72 Gtk::SpinButton output_latency;
73 Gtk::Adjustment input_channels_adjustment;
74 Gtk::SpinButton input_channels;
75 Gtk::Adjustment output_channels_adjustment;
76 Gtk::SpinButton output_channels;
77 Gtk::Adjustment ports_adjustment;
78 Gtk::SpinButton ports_spinner;
80 Gtk::Label have_control_text;
81 Gtk::Button control_app_button;
83 Gtk::Button connect_disconnect_button;
85 /* latency measurement */
87 Gtk::ComboBoxText lm_output_channel_combo;
88 Gtk::ComboBoxText lm_input_channel_combo;
89 Gtk::Label lm_measure_label;
90 Gtk::Button lm_measure_button;
91 Gtk::Button lm_use_button;
92 Gtk::Button lm_back_button;
93 ArdourButton lm_button;
95 Gtk::Label lm_results;
101 Gtk::Button* cancel_button;
102 Gtk::Button* ok_button;
103 Gtk::Button* apply_button;
108 Gtk::Button midi_refresh_button;
109 Gtk::Table midi_device_table;
113 Gtk::CheckButton aj_button;
115 uint32_t ignore_changes;
116 uint32_t _desired_sample_rate;
117 bool started_at_least_once;
119 void driver_changed ();
120 void backend_changed ();
121 void sample_rate_changed ();
122 void buffer_size_changed ();
123 void parameter_changed ();
124 void midi_option_changed ();
126 void setup_midi_tab_for_backend ();
127 void setup_midi_tab_for_jack ();
128 void refresh_midi_display ();
130 std::string bufsize_as_string (uint32_t);
132 float get_rate() const;
133 uint32_t get_buffer_size() const;
134 uint32_t get_input_channels() const;
135 uint32_t get_output_channels() const;
136 uint32_t get_input_latency() const;
137 uint32_t get_output_latency() const;
138 std::string get_device_name() const;
139 std::string get_driver() const;
140 std::string get_backend() const;
141 std::string get_midi_option () const;
143 void device_changed ();
144 void list_devices ();
145 void show_buffer_duration ();
152 uint32_t buffer_size;
153 uint32_t input_latency;
154 uint32_t output_latency;
155 uint32_t input_channels;
156 uint32_t output_channels;
158 std::string midi_option;
164 , output_channels (0)
169 typedef std::list<State> StateList;
173 State* get_matching_state (const std::string& backend,
174 const std::string& driver,
175 const std::string& device);
176 State* get_saved_state_for_currently_displayed_backend_and_device ();
177 void maybe_display_saved_state ();
178 State* save_state ();
179 void store_state (State&);
183 static bool print_channel_count (Gtk::SpinButton*);
185 void build_notebook ();
186 void build_full_control_notebook ();
187 void build_no_control_notebook ();
189 void on_response (int);
190 void control_app_button_clicked ();
191 void use_latency_button_clicked ();
192 void manage_control_app_sensitivity ();
193 int push_state_to_backend (bool start);
195 void update_sensitivity ();
197 /* latency measurement */
198 void latency_button_clicked ();
199 bool check_latency_measurement ();
200 sigc::connection latency_timeout;
201 void enable_latency_tab ();
202 void disable_latency_tab ();
203 void start_latency_detection ();
204 void end_latency_detection ();
206 void on_switch_page (GtkNotebookPage*, guint page_num);
207 bool on_delete_event (GdkEventAny*);
209 void engine_running ();
210 void engine_stopped ();
211 PBD::ScopedConnection running_connection;
212 PBD::ScopedConnection stopped_connection;
214 void connect_disconnect_click ();
215 void calibrate_latency ();
218 #endif /* __gtk2_ardour_engine_dialog_h__ */