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"
40 class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
45 static bool need_setup ();
47 XMLNode& get_state ();
48 void set_state (const XMLNode&);
50 void set_desired_sample_rate (uint32_t);
53 Gtk::Notebook notebook;
55 /* core fields used by all backends */
57 Gtk::Table basic_packer;
61 Gtk::ComboBoxText backend_combo;
62 Gtk::ComboBoxText driver_combo;
63 Gtk::ComboBoxText device_combo;
64 Gtk::ComboBoxText sample_rate_combo;
65 Gtk::ComboBoxText buffer_size_combo;
66 Gtk::Label buffer_size_duration_label;
67 Gtk::Adjustment input_latency_adjustment;
68 Gtk::SpinButton input_latency;
69 Gtk::Adjustment output_latency_adjustment;
70 Gtk::SpinButton output_latency;
71 Gtk::Adjustment input_channels_adjustment;
72 Gtk::SpinButton input_channels;
73 Gtk::Adjustment output_channels_adjustment;
74 Gtk::SpinButton output_channels;
75 Gtk::Adjustment ports_adjustment;
76 Gtk::SpinButton ports_spinner;
78 Gtk::Label have_control_text;
79 Gtk::Button control_app_button;
81 Gtk::Button connect_disconnect_button;
83 /* latency measurement */
85 Gtk::ComboBoxText lm_output_channel_combo;
86 Gtk::ComboBoxText lm_input_channel_combo;
87 Gtk::Label lm_start_stop_label;
88 Gtk::ToggleButton lm_measure_button;
89 Gtk::Button lm_use_button;
91 Gtk::Label lm_results;
96 Gtk::Button* cancel_button;
97 Gtk::Button* ok_button;
98 Gtk::Button* apply_button;
103 Gtk::Button midi_refresh_button;
104 Gtk::Table midi_device_table;
108 Gtk::CheckButton aj_button;
110 uint32_t ignore_changes;
111 uint32_t _desired_sample_rate;
113 bool started_at_least_once;
115 void driver_changed ();
116 void backend_changed ();
117 void sample_rate_changed ();
118 void buffer_size_changed ();
119 void parameter_changed ();
121 void setup_midi_tab_for_backend ();
122 void setup_midi_tab_for_jack ();
123 void refresh_midi_display ();
125 std::string bufsize_as_string (uint32_t);
127 float get_rate() const;
128 uint32_t get_buffer_size() const;
129 uint32_t get_input_channels() const;
130 uint32_t get_output_channels() const;
131 uint32_t get_input_latency() const;
132 uint32_t get_output_latency() const;
133 std::string get_device_name() const;
134 std::string get_driver() const;
135 std::string get_backend() const;
137 void device_changed ();
138 void list_devices ();
139 void show_buffer_duration ();
146 uint32_t buffer_size;
147 uint32_t input_latency;
148 uint32_t output_latency;
149 uint32_t input_channels;
150 uint32_t output_channels;
157 , output_channels (0)
162 typedef std::list<State> StateList;
166 State* get_matching_state (const std::string& backend,
167 const std::string& driver,
168 const std::string& device);
169 State* get_saved_state_for_currently_displayed_backend_and_device ();
170 void maybe_display_saved_state ();
171 State* save_state ();
172 void store_state (State&);
176 static bool print_channel_count (Gtk::SpinButton*);
178 void build_notebook ();
179 void build_full_control_notebook ();
180 void build_no_control_notebook ();
182 void on_response (int);
183 void control_app_button_clicked ();
184 void use_latency_button_clicked ();
185 void manage_control_app_sensitivity ();
186 int push_state_to_backend (bool start);
188 void update_sensitivity ();
190 /* latency measurement */
191 void latency_button_toggled ();
192 bool check_latency_measurement ();
193 sigc::connection latency_timeout;
194 void enable_latency_tab ();
195 void disable_latency_tab ();
196 void start_latency_detection ();
197 void end_latency_detection ();
199 void on_switch_page (GtkNotebookPage*, guint page_num);
200 bool on_delete_event (GdkEventAny*);
202 void engine_running ();
203 void engine_stopped ();
204 PBD::ScopedConnection running_connection;
205 PBD::ScopedConnection stopped_connection;
207 void connect_disconnect_click ();
210 #endif /* __gtk2_ardour_engine_dialog_h__ */