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 ();
|
2015-08-10 09:20:07 -04:00
|
|
|
bool 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);
|
2016-04-18 08:11:22 -04:00
|
|
|
bool try_autostart ();
|
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;
|
|
|
|
|
2015-01-25 04:19:46 -05:00
|
|
|
Gtk::Label engine_status;
|
|
|
|
|
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;
|
2015-05-04 22:59:26 -04:00
|
|
|
Gtk::ComboBoxText input_device_combo;
|
|
|
|
Gtk::ComboBoxText output_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;
|
2015-12-04 19:32:56 -05:00
|
|
|
Gtk::ComboBoxText nperiods_combo;
|
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;
|
2015-08-11 09:34:07 -04:00
|
|
|
ArdourButton control_app_button;
|
2014-06-13 06:01:55 -04:00
|
|
|
ArdourButton midi_devices_button;
|
2015-08-25 07:42:11 -04:00
|
|
|
ArdourButton start_stop_button;
|
2015-08-25 08:57:44 -04:00
|
|
|
ArdourButton update_devices_button;
|
2016-02-05 08:32:59 -05:00
|
|
|
ArdourButton use_buffered_io_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;
|
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
|
|
|
|
2016-01-28 19:12:32 -05:00
|
|
|
uint32_t ignore_changes; // state save/load
|
|
|
|
uint32_t ignore_device_changes; // AudioEngine::DeviceListChanged
|
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;
|
2015-03-07 05:11:50 -05:00
|
|
|
bool queue_device_changed;
|
2013-09-19 15:03:20 -04:00
|
|
|
|
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 ();
|
2015-12-04 19:32:56 -05:00
|
|
|
void nperiods_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 ();
|
2016-10-19 17:44:54 -04:00
|
|
|
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
|
|
|
|
2015-08-09 22:49:42 -04:00
|
|
|
void update_midi_options ();
|
|
|
|
|
2015-12-04 19:32:56 -05:00
|
|
|
std::string bufsize_as_string (uint32_t);
|
|
|
|
std::string nperiods_as_string (uint32_t);
|
2013-09-17 10:01:24 -04:00
|
|
|
|
2015-08-11 00:13:06 -04:00
|
|
|
std::vector<float> get_default_sample_rates ();
|
|
|
|
std::vector<uint32_t> get_default_buffer_sizes ();
|
|
|
|
|
2015-08-10 23:02:25 -04:00
|
|
|
std::vector<float> get_sample_rates_for_all_devices ();
|
|
|
|
std::vector<uint32_t> get_buffer_sizes_for_all_devices ();
|
|
|
|
|
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;
|
2015-12-04 19:32:56 -05:00
|
|
|
uint32_t get_nperiods() const;
|
2013-08-05 12:51:51 -04:00
|
|
|
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;
|
2015-05-04 22:59:26 -04:00
|
|
|
std::string get_input_device_name() const;
|
|
|
|
std::string get_output_device_name() const;
|
2013-08-05 12:51:51 -04:00
|
|
|
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;
|
2016-02-05 08:32:59 -05:00
|
|
|
bool get_use_buffered_io () const;
|
2013-08-05 12:51:51 -04:00
|
|
|
|
2015-08-25 10:16:36 -04:00
|
|
|
std::string get_default_device (const std::string&,
|
|
|
|
const std::vector<std::string>&);
|
|
|
|
|
2013-09-04 12:37:44 -04:00
|
|
|
void device_changed ();
|
2015-05-04 22:59:26 -04:00
|
|
|
void input_device_changed ();
|
|
|
|
void output_device_changed ();
|
2015-07-29 01:46:26 -04:00
|
|
|
bool set_driver_popdown_strings ();
|
2015-05-04 22:59:26 -04:00
|
|
|
bool set_device_popdown_strings ();
|
|
|
|
bool set_input_device_popdown_strings ();
|
|
|
|
bool set_output_device_popdown_strings ();
|
2015-08-10 23:02:25 -04:00
|
|
|
void set_samplerate_popdown_strings ();
|
|
|
|
void set_buffersize_popdown_strings ();
|
2015-12-04 19:32:56 -05:00
|
|
|
void set_nperiods_popdown_strings ();
|
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;
|
2015-05-04 22:59:26 -04:00
|
|
|
std::string input_device;
|
|
|
|
std::string output_device;
|
2013-09-17 21:09:13 -04:00
|
|
|
float sample_rate;
|
|
|
|
uint32_t buffer_size;
|
2015-12-04 19:32:56 -05:00
|
|
|
uint32_t n_periods;
|
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;
|
2016-02-05 08:32:59 -05:00
|
|
|
bool use_buffered_io;
|
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;
|
2015-11-23 16:44:13 -05:00
|
|
|
time_t lru;
|
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)
|
2015-11-23 16:44:13 -05:00
|
|
|
, active (false)
|
2016-02-05 08:32:59 -05:00
|
|
|
, use_buffered_io (false)
|
2015-11-23 16:44:13 -05:00
|
|
|
, lru (0) {}
|
2013-09-17 21:09:13 -04:00
|
|
|
|
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;
|
2015-11-23 16:44:13 -05:00
|
|
|
static bool state_sort_cmp (const State &a, const State &b);
|
2013-09-04 15:45:54 -04:00
|
|
|
|
|
|
|
StateList states;
|
|
|
|
|
2015-11-23 15:44:13 -05:00
|
|
|
State get_matching_state (const std::string& backend);
|
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);
|
2015-05-04 22:59:26 -04:00
|
|
|
State get_matching_state (const std::string& backend,
|
|
|
|
const std::string& driver,
|
|
|
|
const std::string& input_device,
|
|
|
|
const std::string& output_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);
|
2015-05-04 22:59:26 -04:00
|
|
|
bool equivalent_states (const State&, const State&);
|
2013-09-17 21:09:13 -04:00
|
|
|
|
2015-08-10 09:20:07 -04:00
|
|
|
bool set_current_state (const State& state);
|
|
|
|
void set_default_state ();
|
2015-08-08 19:39:01 -04:00
|
|
|
|
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
|
|
|
|
2015-08-09 08:36:26 -04:00
|
|
|
void connect_changed_signals ();
|
2015-08-09 09:16:02 -04:00
|
|
|
void block_changed_signals ();
|
|
|
|
void unblock_changed_signals ();
|
|
|
|
|
|
|
|
class SignalBlocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SignalBlocker (EngineControl& engine_control, const std::string& reason);
|
|
|
|
|
|
|
|
~SignalBlocker ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
EngineControl& ec;
|
|
|
|
std::string m_reason;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t block_signals;
|
|
|
|
|
|
|
|
sigc::connection backend_combo_connection;
|
|
|
|
sigc::connection driver_combo_connection;
|
|
|
|
sigc::connection sample_rate_combo_connection;
|
|
|
|
sigc::connection buffer_size_combo_connection;
|
2015-12-04 19:32:56 -05:00
|
|
|
sigc::connection nperiods_combo_connection;
|
2015-08-09 09:16:02 -04:00
|
|
|
sigc::connection device_combo_connection;
|
|
|
|
sigc::connection input_device_combo_connection;
|
|
|
|
sigc::connection output_device_combo_connection;
|
|
|
|
sigc::connection midi_option_combo_connection;
|
|
|
|
sigc::connection input_latency_connection;
|
|
|
|
sigc::connection output_latency_connection;
|
|
|
|
sigc::connection input_channels_connection;
|
|
|
|
sigc::connection output_channels_connection;
|
2015-08-09 08:36:26 -04:00
|
|
|
|
2014-09-01 16:06:45 -04:00
|
|
|
void on_show ();
|
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 ();
|
2015-08-25 07:42:11 -04:00
|
|
|
void start_stop_button_clicked ();
|
2015-08-25 08:57:44 -04:00
|
|
|
void update_devices_button_clicked ();
|
2016-02-05 08:32:59 -05:00
|
|
|
void use_buffered_io_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 ();
|
2015-08-11 08:43:00 -04:00
|
|
|
void update_sensitivity ();
|
2015-10-02 21:40:34 -04:00
|
|
|
bool start_engine ();
|
2015-12-04 11:34:46 -05:00
|
|
|
bool stop_engine (bool for_latency = false);
|
2013-09-10 22:58:33 -04:00
|
|
|
|
|
|
|
/* latency measurement */
|
2013-10-12 14:57:32 -04:00
|
|
|
void latency_button_clicked ();
|
2015-10-03 01:49:55 -04:00
|
|
|
void latency_back_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 ();
|
2015-03-06 00:24:44 -05:00
|
|
|
void device_list_changed ();
|
|
|
|
|
2013-09-19 15:03:20 -04:00
|
|
|
PBD::ScopedConnection running_connection;
|
2015-01-17 15:02:00 -05:00
|
|
|
PBD::ScopedConnectionList stopped_connection;
|
2015-03-06 00:24:44 -05:00
|
|
|
PBD::ScopedConnection devicelist_connection;
|
2013-09-19 15:03:20 -04:00
|
|
|
|
|
|
|
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__ */
|