2010-07-25 21:54:51 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
#ifndef __gtk2_ardour_engine_dialog_h__
|
|
|
|
#define __gtk2_ardour_engine_dialog_h__
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <gtkmm/checkbutton.h>
|
|
|
|
#include <gtkmm/spinbutton.h>
|
|
|
|
#include <gtkmm/comboboxtext.h>
|
|
|
|
#include <gtkmm/table.h>
|
|
|
|
#include <gtkmm/expander.h>
|
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/buttonbox.h>
|
|
|
|
#include <gtkmm/button.h>
|
|
|
|
|
2013-09-10 22:58:33 -04:00
|
|
|
#include "pbd/signals.h"
|
|
|
|
|
2013-09-09 13:17:53 -04:00
|
|
|
#include "ardour_dialog.h"
|
2013-10-12 14:57:32 -04:00
|
|
|
#include "ardour_button.h"
|
2013-09-09 13:17:53 -04:00
|
|
|
|
2013-09-10 22:58:33 -04:00
|
|
|
class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
|
2007-10-11 18:07:47 -04:00
|
|
|
public:
|
2013-09-10 15:41:19 -04:00
|
|
|
EngineControl ();
|
|
|
|
~EngineControl ();
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-10 15:41:19 -04:00
|
|
|
static bool need_setup ();
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-10 15:41:19 -04:00
|
|
|
XMLNode& get_state ();
|
|
|
|
void set_state (const XMLNode&);
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-10 15:41:19 -04:00
|
|
|
void set_desired_sample_rate (uint32_t);
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
private:
|
2013-08-09 00:50:41 -04:00
|
|
|
Gtk::Notebook notebook;
|
|
|
|
|
2013-08-04 14:03:19 -04:00
|
|
|
/* core fields used by all backends */
|
|
|
|
|
2013-09-17 10:01:24 -04:00
|
|
|
Gtk::Table basic_packer;
|
|
|
|
Gtk::HBox basic_hbox;
|
|
|
|
Gtk::VBox basic_vbox;
|
|
|
|
|
2013-08-04 14:03:19 -04:00
|
|
|
Gtk::ComboBoxText backend_combo;
|
2013-09-17 10:01:24 -04:00
|
|
|
Gtk::ComboBoxText driver_combo;
|
|
|
|
Gtk::ComboBoxText device_combo;
|
2013-08-04 14:03:19 -04:00
|
|
|
Gtk::ComboBoxText sample_rate_combo;
|
2013-10-10 12:59:33 -04:00
|
|
|
Gtk::ComboBoxText midi_option_combo;
|
2013-08-04 14:03:19 -04:00
|
|
|
Gtk::ComboBoxText buffer_size_combo;
|
2013-09-06 21:00:01 -04:00
|
|
|
Gtk::Label buffer_size_duration_label;
|
2013-08-04 14:03:19 -04:00
|
|
|
Gtk::Adjustment input_latency_adjustment;
|
|
|
|
Gtk::SpinButton input_latency;
|
|
|
|
Gtk::Adjustment output_latency_adjustment;
|
|
|
|
Gtk::SpinButton output_latency;
|
|
|
|
Gtk::Adjustment input_channels_adjustment;
|
|
|
|
Gtk::SpinButton input_channels;
|
|
|
|
Gtk::Adjustment output_channels_adjustment;
|
|
|
|
Gtk::SpinButton output_channels;
|
|
|
|
Gtk::Adjustment ports_adjustment;
|
|
|
|
Gtk::SpinButton ports_spinner;
|
|
|
|
|
2013-09-19 15:03:20 -04:00
|
|
|
Gtk::Label have_control_text;
|
2013-09-09 15:17:29 -04:00
|
|
|
Gtk::Button control_app_button;
|
2014-06-13 06:01:55 -04:00
|
|
|
ArdourButton midi_devices_button;
|
2013-09-09 15:17:29 -04:00
|
|
|
|
2013-09-19 15:03:20 -04:00
|
|
|
Gtk::Button connect_disconnect_button;
|
|
|
|
|
2013-09-10 22:58:33 -04:00
|
|
|
/* latency measurement */
|
|
|
|
|
|
|
|
Gtk::ComboBoxText lm_output_channel_combo;
|
|
|
|
Gtk::ComboBoxText lm_input_channel_combo;
|
2013-10-15 14:55:54 -04:00
|
|
|
Gtk::Label lm_measure_label;
|
2013-10-12 14:57:32 -04:00
|
|
|
Gtk::Button lm_measure_button;
|
2013-09-10 22:58:33 -04:00
|
|
|
Gtk::Button lm_use_button;
|
2013-10-12 14:57:32 -04:00
|
|
|
Gtk::Button lm_back_button;
|
2014-06-08 08:48:10 -04:00
|
|
|
ArdourButton lm_button_audio;
|
2013-09-10 22:58:33 -04:00
|
|
|
Gtk::Label lm_title;
|
2014-06-16 17:36:29 -04:00
|
|
|
Gtk::Label lm_preamble;
|
2013-09-10 22:58:33 -04:00
|
|
|
Gtk::Label lm_results;
|
|
|
|
Gtk::Table lm_table;
|
|
|
|
Gtk::VBox lm_vbox;
|
2013-09-16 15:21:32 -04:00
|
|
|
bool have_lm_results;
|
2013-10-12 14:57:32 -04:00
|
|
|
bool lm_running;
|
2013-09-16 15:21:32 -04:00
|
|
|
|
|
|
|
Gtk::Button* cancel_button;
|
|
|
|
Gtk::Button* ok_button;
|
|
|
|
Gtk::Button* apply_button;
|
2013-09-10 22:58:33 -04:00
|
|
|
|
2013-09-17 10:01:24 -04:00
|
|
|
/* MIDI Tab */
|
|
|
|
|
|
|
|
Gtk::VBox midi_vbox;
|
2014-06-13 06:01:55 -04:00
|
|
|
Gtk::Button midi_back_button;
|
2013-09-17 10:01:24 -04:00
|
|
|
Gtk::Table midi_device_table;
|
|
|
|
|
|
|
|
/* MIDI ... JACK */
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-17 10:01:24 -04:00
|
|
|
Gtk::CheckButton aj_button;
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-09 21:23:12 -04:00
|
|
|
uint32_t ignore_changes;
|
2013-09-17 10:01:24 -04:00
|
|
|
uint32_t _desired_sample_rate;
|
2013-09-19 15:03:20 -04:00
|
|
|
bool started_at_least_once;
|
|
|
|
|
2013-08-04 14:03:19 -04:00
|
|
|
void driver_changed ();
|
|
|
|
void backend_changed ();
|
2013-09-04 15:45:54 -04:00
|
|
|
void sample_rate_changed ();
|
|
|
|
void buffer_size_changed ();
|
2013-09-12 16:28:51 -04:00
|
|
|
void parameter_changed ();
|
2013-10-10 16:18:27 -04:00
|
|
|
void midi_option_changed ();
|
2013-08-04 14:03:19 -04:00
|
|
|
|
2013-09-17 10:01:24 -04:00
|
|
|
void setup_midi_tab_for_backend ();
|
|
|
|
void setup_midi_tab_for_jack ();
|
2014-06-13 18:06:52 -04:00
|
|
|
void refresh_midi_display (std::string focus = "");
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-17 21:09:13 -04:00
|
|
|
std::string bufsize_as_string (uint32_t);
|
2013-09-17 10:01:24 -04:00
|
|
|
|
2013-09-17 21:09:13 -04:00
|
|
|
float get_rate() const;
|
2013-08-05 12:51:51 -04:00
|
|
|
uint32_t get_buffer_size() const;
|
|
|
|
uint32_t get_input_channels() const;
|
|
|
|
uint32_t get_output_channels() const;
|
|
|
|
uint32_t get_input_latency() const;
|
|
|
|
uint32_t get_output_latency() const;
|
|
|
|
std::string get_device_name() const;
|
|
|
|
std::string get_driver() const;
|
2013-09-17 21:09:13 -04:00
|
|
|
std::string get_backend() const;
|
2013-10-10 16:18:27 -04:00
|
|
|
std::string get_midi_option () const;
|
2013-08-05 12:51:51 -04:00
|
|
|
|
2013-09-04 12:37:44 -04:00
|
|
|
void device_changed ();
|
2013-08-04 14:03:19 -04:00
|
|
|
void list_devices ();
|
2013-09-06 21:00:01 -04:00
|
|
|
void show_buffer_duration ();
|
2013-09-04 15:45:54 -04:00
|
|
|
|
2014-06-13 06:01:55 -04:00
|
|
|
void configure_midi_devices ();
|
|
|
|
|
|
|
|
struct MidiDeviceSetting {
|
|
|
|
std::string name;
|
|
|
|
bool enabled;
|
|
|
|
uint32_t input_latency;
|
|
|
|
uint32_t output_latency;
|
|
|
|
|
|
|
|
MidiDeviceSetting (std::string n, bool en = true, uint32_t inl = 0, uint32_t oul = 0)
|
|
|
|
: name (n)
|
|
|
|
, enabled (en)
|
|
|
|
, input_latency (inl)
|
|
|
|
, output_latency (oul)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::shared_ptr<MidiDeviceSetting> MidiDeviceSettings;
|
|
|
|
bool _can_set_midi_latencies;
|
|
|
|
std::vector<MidiDeviceSettings> _midi_devices;
|
|
|
|
|
|
|
|
MidiDeviceSettings find_midi_device(std::string devicename) const {
|
|
|
|
for (std::vector<MidiDeviceSettings>::const_iterator p = _midi_devices.begin(); p != _midi_devices.end(); ++p) {
|
|
|
|
if ((*p)->name == devicename) {
|
|
|
|
return *p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MidiDeviceSettings();
|
|
|
|
}
|
|
|
|
|
2014-06-14 22:54:39 -04:00
|
|
|
struct StateStruct {
|
2013-09-04 19:34:43 -04:00
|
|
|
std::string backend;
|
|
|
|
std::string driver;
|
|
|
|
std::string device;
|
2013-09-17 21:09:13 -04:00
|
|
|
float sample_rate;
|
|
|
|
uint32_t buffer_size;
|
2013-09-06 16:43:02 -04:00
|
|
|
uint32_t input_latency;
|
|
|
|
uint32_t output_latency;
|
|
|
|
uint32_t input_channels;
|
|
|
|
uint32_t output_channels;
|
2013-09-04 22:58:56 -04:00
|
|
|
bool active;
|
2013-10-10 12:59:33 -04:00
|
|
|
std::string midi_option;
|
2014-06-13 06:01:55 -04:00
|
|
|
std::vector<MidiDeviceSettings> midi_devices;
|
2013-09-04 22:58:56 -04:00
|
|
|
|
2014-06-14 22:54:39 -04:00
|
|
|
StateStruct()
|
2014-06-22 22:26:53 -04:00
|
|
|
: sample_rate (48000)
|
|
|
|
, buffer_size (1024)
|
|
|
|
, input_latency (0)
|
2013-09-17 21:09:13 -04:00
|
|
|
, output_latency (0)
|
|
|
|
, input_channels (0)
|
|
|
|
, output_channels (0)
|
|
|
|
, active (false) {}
|
|
|
|
|
2013-09-04 15:45:54 -04:00
|
|
|
};
|
2014-06-14 22:54:39 -04:00
|
|
|
|
|
|
|
typedef boost::shared_ptr<StateStruct> State;
|
2013-09-04 15:45:54 -04:00
|
|
|
typedef std::list<State> StateList;
|
|
|
|
|
|
|
|
StateList states;
|
|
|
|
|
2014-06-14 22:54:39 -04:00
|
|
|
State get_matching_state (const std::string& backend,
|
2013-09-04 15:45:54 -04:00
|
|
|
const std::string& driver,
|
|
|
|
const std::string& device);
|
2014-06-14 22:54:39 -04:00
|
|
|
State get_saved_state_for_currently_displayed_backend_and_device ();
|
2013-09-09 21:23:12 -04:00
|
|
|
void maybe_display_saved_state ();
|
2014-06-14 22:54:39 -04:00
|
|
|
State save_state ();
|
|
|
|
void store_state (State);
|
2013-09-17 21:09:13 -04:00
|
|
|
|
|
|
|
bool _have_control;
|
2013-09-06 21:00:01 -04:00
|
|
|
|
|
|
|
static bool print_channel_count (Gtk::SpinButton*);
|
2013-09-09 13:17:53 -04:00
|
|
|
|
|
|
|
void build_notebook ();
|
2013-09-19 15:03:20 -04:00
|
|
|
void build_full_control_notebook ();
|
|
|
|
void build_no_control_notebook ();
|
2013-09-09 13:17:53 -04:00
|
|
|
|
|
|
|
void on_response (int);
|
2013-09-09 15:17:29 -04:00
|
|
|
void control_app_button_clicked ();
|
2013-09-11 13:02:32 -04:00
|
|
|
void use_latency_button_clicked ();
|
2013-09-09 15:17:29 -04:00
|
|
|
void manage_control_app_sensitivity ();
|
2013-09-09 21:23:12 -04:00
|
|
|
int push_state_to_backend (bool start);
|
2013-09-17 21:09:13 -04:00
|
|
|
void post_push ();
|
2013-09-19 15:03:20 -04:00
|
|
|
void update_sensitivity ();
|
2013-09-10 22:58:33 -04:00
|
|
|
|
|
|
|
/* latency measurement */
|
2013-10-12 14:57:32 -04:00
|
|
|
void latency_button_clicked ();
|
2014-06-08 08:48:10 -04:00
|
|
|
bool check_audio_latency_measurement ();
|
|
|
|
bool check_midi_latency_measurement ();
|
2013-09-10 22:58:33 -04:00
|
|
|
sigc::connection latency_timeout;
|
|
|
|
void enable_latency_tab ();
|
|
|
|
void disable_latency_tab ();
|
2013-09-16 18:47:30 -04:00
|
|
|
void start_latency_detection ();
|
|
|
|
void end_latency_detection ();
|
2014-06-14 22:54:39 -04:00
|
|
|
|
2013-09-12 16:28:51 -04:00
|
|
|
void on_switch_page (GtkNotebookPage*, guint page_num);
|
2013-09-16 18:47:30 -04:00
|
|
|
bool on_delete_event (GdkEventAny*);
|
2013-09-19 15:03:20 -04:00
|
|
|
|
|
|
|
void engine_running ();
|
|
|
|
void engine_stopped ();
|
|
|
|
PBD::ScopedConnection running_connection;
|
|
|
|
PBD::ScopedConnection stopped_connection;
|
|
|
|
|
|
|
|
void connect_disconnect_click ();
|
2014-06-08 08:48:10 -04:00
|
|
|
void calibrate_audio_latency ();
|
2014-06-13 06:01:55 -04:00
|
|
|
void calibrate_midi_latency (MidiDeviceSettings);
|
|
|
|
|
|
|
|
MidiDeviceSettings _measure_midi;
|
|
|
|
void midi_latency_adjustment_changed(Gtk::Adjustment *, MidiDeviceSettings, bool);
|
2014-06-13 18:06:52 -04:00
|
|
|
void midi_device_enabled_toggled(ArdourButton *, MidiDeviceSettings);
|
2014-06-13 06:01:55 -04:00
|
|
|
sigc::connection lm_back_button_signal;
|
2007-10-11 18:07:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk2_ardour_engine_dialog_h__ */
|