summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/ardour3_ui_dark.rc.in2
-rw-r--r--gtk2_ardour/ardour_ui.cc37
-rw-r--r--gtk2_ardour/ardour_ui.h6
-rw-r--r--gtk2_ardour/ardour_ui2.cc38
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc1
-rw-r--r--gtk2_ardour/ardour_ui_options.cc71
-rw-r--r--gtk2_ardour/editor_ops.cc15
-rw-r--r--gtk2_ardour/option_editor.h5
-rw-r--r--gtk2_ardour/session_option_editor.cc32
-rw-r--r--gtk2_ardour/session_option_editor.h1
-rw-r--r--libs/ardour/ardour/rc_configuration_vars.h1
-rw-r--r--libs/ardour/ardour/session.h14
-rw-r--r--libs/ardour/ardour/session_configuration_vars.h2
-rw-r--r--libs/ardour/ardour/types.h9
-rw-r--r--libs/ardour/ardour/utils.h4
-rw-r--r--libs/ardour/enums.cc13
-rw-r--r--libs/ardour/globals.cc25
-rw-r--r--libs/ardour/rc_configuration.cc7
-rw-r--r--libs/ardour/session.cc18
-rw-r--r--libs/ardour/session_events.cc4
-rw-r--r--libs/ardour/session_export.cc8
-rw-r--r--libs/ardour/session_midi.cc10
-rw-r--r--libs/ardour/session_process.cc4
-rw-r--r--libs/ardour/session_state.cc17
-rw-r--r--libs/ardour/session_transport.cc59
-rw-r--r--libs/ardour/utils.cc25
-rw-r--r--libs/midi++2/factory.cc6
-rw-r--r--libs/midi++2/manager.cc7
-rw-r--r--libs/midi++2/wscript20
-rw-r--r--wscript21
30 files changed, 279 insertions, 203 deletions
diff --git a/gtk2_ardour/ardour3_ui_dark.rc.in b/gtk2_ardour/ardour3_ui_dark.rc.in
index 7d6c2621de..01f0085fba 100644
--- a/gtk2_ardour/ardour3_ui_dark.rc.in
+++ b/gtk2_ardour/ardour3_ui_dark.rc.in
@@ -1528,6 +1528,8 @@ widget "*BypassButton" style:highest "red_when_active"
widget "*BypassButton*" style:highest "red_when_active"
widget "*TransportSoloAlert" style:highest "flashing_alert"
widget "*TransportSoloAlert.*" style:highest "flashing_alert"
+widget "*TransportSyncAlert" style:highest "flashing_alert"
+widget "*TransportSyncAlert.*" style:highest "flashing_alert"
widget "*SendAlert" style:highest "green_flashing_alert"
widget "*SendAlert.*" style:highest "green_flashing_alert"
widget "*TransportAuditioningAlert" style:highest "flashing_alert"
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 16a96f1e45..f7c28b49f1 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -338,7 +338,7 @@ ARDOUR_UI::post_engine ()
MIDI::Manager::instance()->set_api_data (engine->jack());
setup_midi ();
-
+
ARDOUR::init_post_engine ();
ActionManager::init ();
@@ -347,7 +347,7 @@ ARDOUR_UI::post_engine ()
if (setup_windows ()) {
throw failed_constructor ();
}
-
+
check_memory_locking();
/* this is the first point at which all the keybindings are available */
@@ -398,6 +398,9 @@ ARDOUR_UI::post_engine ()
update_cpu_load ();
update_sample_rate (engine->frame_rate());
+ Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
+ Config->map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
+
/* now start and maybe save state */
if (do_engine_start () == 0) {
@@ -1524,13 +1527,14 @@ ARDOUR_UI::transport_roll ()
return;
}
- switch (Config->get_slave_source()) {
- case None:
- case JACK:
- break;
- default:
- /* transport controlled by the master */
- return;
+ if (session->config.get_external_sync()) {
+ switch (session->config.get_sync_source()) {
+ case JACK:
+ break;
+ default:
+ /* transport controlled by the master */
+ return;
+ }
}
bool rolling = session->transport_rolling();
@@ -1561,13 +1565,14 @@ ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
return;
}
- switch (Config->get_slave_source()) {
- case None:
- case JACK:
- break;
- default:
- /* transport controlled by the master */
- return;
+ if (session->config.get_external_sync()) {
+ switch (session->config.get_sync_source()) {
+ case JACK:
+ break;
+ default:
+ /* transport controlled by the master */
+ return;
+ }
}
bool rolling = session->transport_rolling();
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 59a5f22665..6a8d790915 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -385,9 +385,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI
BindableButton play_selection_button;
BindableButton rec_button;
- Gtk::ComboBoxText sync_option_combo;
+ Gtk::ToggleButton sync_button;
- void sync_option_changed ();
+ void sync_button_clicked ();
void toggle_time_master ();
void toggle_video_sync ();
@@ -434,6 +434,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
Gtk::VBox alert_box;
void solo_blink (bool);
+ void sync_blink (bool);
void audition_blink (bool);
void soloing_changed (bool);
@@ -671,7 +672,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void toggle_use_osc ();
- void mtc_port_changed ();
void parameter_changed (std::string);
bool first_idle ();
diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc
index e2f4db7e5a..7f7d46150c 100644
--- a/gtk2_ardour/ardour_ui2.cc
+++ b/gtk2_ardour/ardour_ui2.cc
@@ -239,7 +239,7 @@ ARDOUR_UI::setup_transport ()
ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
- ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo, _("Positional sync source"));
+ ARDOUR_UI::instance()->tooltips().set_tip (sync_button, _("Positional sync source"));
ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
@@ -331,11 +331,10 @@ ARDOUR_UI::setup_transport ()
sdframe->set_shadow_type (SHADOW_IN);
sdframe->add (speed_display_box);
- mtc_port_changed ();
- sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
- // XXX HOW TO USE set_popdown_strings() and combo_fudge with this when we don't know
- // the real strings till later?
- set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 4+COMBO_FUDGE, 10);
+ sync_button.set_name ("TransportSyncAlert");
+ sync_button.signal_clicked().connect (mem_fun (*this, &ARDOUR_UI::sync_button_clicked));
+ // XXX HOW TO USE set_popdown_strings() with this when we don't know the real strings till later?
+ set_size_request_to_display_given_text (sync_button, X_("Egternal"), 4, 10);
shbox->pack_start (*sdframe, false, false);
shbox->pack_start (shuttle_units_button, true, true);
@@ -362,7 +361,7 @@ ARDOUR_UI::setup_transport ()
if (!Profile->get_sae()) {
VBox* time_controls_box = manage (new VBox);
- time_controls_box->pack_start (sync_option_combo, false, false);
+ time_controls_box->pack_start (sync_button, false, false);
time_controls_box->pack_start (time_master_button, false, false);
clock_box->pack_start (*time_controls_box, false, false, 1);
}
@@ -486,6 +485,24 @@ ARDOUR_UI::solo_blink (bool onoff)
}
void
+ARDOUR_UI::sync_blink (bool onoff)
+{
+ if (session == 0 || !session->config.get_external_sync()) {
+ return;
+ }
+
+ if (!session->transport_locked()) {
+ if (onoff) {
+ sync_button.set_state (STATE_ACTIVE);
+ } else {
+ sync_button.set_state (STATE_NORMAL);
+ }
+ } else {
+ sync_button.set_state (STATE_NORMAL);
+ }
+}
+
+void
ARDOUR_UI::audition_blink (bool onoff)
{
if (session == 0) {
@@ -846,13 +863,10 @@ ARDOUR_UI::editor_realized ()
}
void
-ARDOUR_UI::sync_option_changed ()
+ARDOUR_UI::sync_button_clicked ()
{
if (session) {
- ustring txt = sync_option_combo.get_active_text ();
- if (txt.length()) {
- session->request_slave_source (string_to_slave_source (txt));
- }
+ session->config.set_external_sync (sync_button.get_active());
}
}
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc
index cfb3d6574e..eb7836ba06 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -105,6 +105,7 @@ ARDOUR_UI::connect_to_session (Session *s)
Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
+ Blink.connect (mem_fun(*this, &ARDOUR_UI::sync_blink));
Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
/* these are all need to be handled in an RT-safe and MT way, so don't
diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc
index 663bb8eaff..8f16b9578a 100644
--- a/gtk2_ardour/ardour_ui_options.cc
+++ b/gtk2_ardour/ardour_ui_options.cc
@@ -263,70 +263,51 @@ ARDOUR_UI::toggle_editing_space()
}
void
-ARDOUR_UI::mtc_port_changed ()
+ARDOUR_UI::setup_session_options ()
{
- bool have_mtc;
- bool have_midi_clock;
-
- if (session) {
- if (session->mtc_port()) {
- have_mtc = true;
- } else {
- have_mtc = false;
- }
- if (session->midi_clock_port()) {
- have_midi_clock = true;
- } else {
- have_midi_clock = false;
- }
- } else {
- have_mtc = false;
- have_midi_clock = false;
- }
-
- positional_sync_strings.clear ();
- positional_sync_strings.push_back (slave_source_to_string (None));
- if (have_mtc) {
- positional_sync_strings.push_back (slave_source_to_string (MTC));
- }
- if (have_midi_clock) {
- positional_sync_strings.push_back (slave_source_to_string (MIDIClock));
- }
- positional_sync_strings.push_back (slave_source_to_string (JACK));
-
- set_popdown_strings (sync_option_combo, positional_sync_strings);
+ session->config.ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
+ session->config.map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
}
+#if 0
void
-ARDOUR_UI::setup_session_options ()
+ARDOUR_UI::handle_sync_change ()
{
- mtc_port_changed ();
+ if (!session) {
+ return;
+ }
+ if (!session->config.get_external_sync()) {
+ sync_button.set_label (_("Internal"));
+ ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
+ ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
+ } else {
+ sync_button.set_label (_("External"));
+ /* XXX need to make auto-play is off as well as insensitive */
+ ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
+ ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
+ }
- Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
}
+#endif
void
ARDOUR_UI::parameter_changed (std::string p)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), p));
- if (p == "slave-source") {
-
- sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
-
- switch (Config->get_slave_source()) {
- case None:
+ if (p == "external-sync") {
+
+ if (!session->config.get_external_sync()) {
+ sync_button.set_label (_("Internal"));
ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
- break;
-
- default:
+ } else {
+ sync_button.set_label (sync_source_to_string (session->config.get_sync_source()));
/* XXX need to make auto-play is off as well as insensitive */
ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
- break;
}
-
+
} else if (p == "send-mtc") {
ActionManager::map_some_state ("options", "SendMTC", &RCConfiguration::get_send_mtc);
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index c9a5870df0..001e56da35 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2350,13 +2350,14 @@ Editor::transition_to_rolling (bool fwd)
return;
}
- switch (Config->get_slave_source()) {
- case None:
- case JACK:
- break;
- default:
- /* transport controlled by the master */
- return;
+ if (session->config.get_external_sync()) {
+ switch (session->config.get_sync_source()) {
+ case JACK:
+ break;
+ default:
+ /* transport controlled by the master */
+ return;
+ }
}
if (session->is_auditioning()) {
diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h
index f5509c760c..3a5281af0c 100644
--- a/gtk2_ardour/option_editor.h
+++ b/gtk2_ardour/option_editor.h
@@ -231,6 +231,11 @@ public:
_combo->append_text (o);
}
+ void clear () {
+ _combo->clear_items();
+ _options.clear ();
+ }
+
void changed () {
uint32_t const r = _combo->get_active_row_number ();
if (r < _options.size()) {
diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc
index ab774ffc18..49dbcdff15 100644
--- a/gtk2_ardour/session_option_editor.cc
+++ b/gtk2_ardour/session_option_editor.cc
@@ -138,8 +138,8 @@ private:
};
SessionOptionEditor::SessionOptionEditor (Session* s)
- : OptionEditor (&(s->config), _("Session Preferences")),
- _session_config (&(s->config))
+ : OptionEditor (&(s->config), _("Session Preferences"))
+ , _session_config (&(s->config))
{
/* FADES */
@@ -222,6 +222,19 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
add_option (_("Sync"), spf);
+ ComboOption<SyncSource>* ssrc = new ComboOption<SyncSource> (
+ "sync-source",
+ _("External sync source"),
+ mem_fun (*_session_config, &SessionConfiguration::get_sync_source),
+ mem_fun (*_session_config, &SessionConfiguration::set_sync_source)
+ );
+
+ s->MTC_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc));
+ s->MIDIClock_PortChanged.connect (bind (mem_fun (*this, &SessionOptionEditor::populate_sync_options), s, ssrc));
+ populate_sync_options (s, ssrc);
+
+ add_option (_("Sync"), ssrc);
+
ComboOption<TimecodeFormat>* smf = new ComboOption<TimecodeFormat> (
"timecode-format",
_("Timecode frames-per-second"),
@@ -332,3 +345,18 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
add_option (_("Connections"), new ConnectionOptions (this, s));
}
+
+void
+SessionOptionEditor::populate_sync_options (Session* s, Option* opt)
+{
+ ComboOption<SyncSource>* sync_opt = dynamic_cast<ComboOption<SyncSource>* > (opt);
+
+ vector<SyncSource> sync_opts = s->get_available_sync_options ();
+
+ sync_opt->clear ();
+
+ for (vector<SyncSource>::iterator i = sync_opts.begin(); i != sync_opts.end(); ++i) {
+ sync_opt->add (*i, sync_source_to_string (*i));
+ }
+}
+
diff --git a/gtk2_ardour/session_option_editor.h b/gtk2_ardour/session_option_editor.h
index 7760f530c4..a2dc750cd2 100644
--- a/gtk2_ardour/session_option_editor.h
+++ b/gtk2_ardour/session_option_editor.h
@@ -12,4 +12,5 @@ public:
private:
ARDOUR::SessionConfiguration* _session_config;
+ void populate_sync_options (ARDOUR::Session*, Option*);
};
diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h
index 5b0be5cccf..f8e61bff79 100644
--- a/libs/ardour/ardour/rc_configuration_vars.h
+++ b/libs/ardour/ardour/rc_configuration_vars.h
@@ -108,7 +108,6 @@ CONFIG_VARIABLE (nframes_t, postroll, "postroll", 0)
CONFIG_VARIABLE (float, rf_speed, "rf-speed", 2.0f)
CONFIG_VARIABLE (float, shuttle_speed_factor, "shuttle-speed-factor", 1.0f)
CONFIG_VARIABLE (float, shuttle_speed_threshold, "shuttle-speed-threshold", 5.0f)
-CONFIG_VARIABLE (SlaveSource, slave_source, "slave-source", None)
CONFIG_VARIABLE (ShuttleBehaviour, shuttle_behaviour, "shuttle-behaviour", Sprung)
CONFIG_VARIABLE (ShuttleUnits, shuttle_units, "shuttle-units", Percentage)
CONFIG_VARIABLE (bool, primary_clock_delta_edit_cursor, "primary-clock-delta-edit-cursor", false)
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 6ac36f98b6..d36bc51079 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -145,7 +145,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
RangeStop,
RangeLocate,
Overwrite,
- SetSlaveSource,
+ SetSyncSource,
Audition,
InputConfigurationChange,
SetPlayAudioRange,
@@ -173,7 +173,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
void* ptr;
bool yes_or_no;
nframes64_t target2_frame;
- SlaveSource slave;
+ SyncSource sync_source;
Route* route;
};
@@ -576,8 +576,9 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
static sigc::signal<void> EndTimeChanged;
static sigc::signal<void> TimecodeOffsetChanged;
- void request_slave_source (SlaveSource);
- bool synced_to_jack() const { return Config->get_slave_source() == JACK; }
+ std::vector<SyncSource> get_available_sync_options() const;
+ void request_sync_source (SyncSource);
+ bool synced_to_jack() const { return config.get_external_sync() && config.get_sync_source() == JACK; }
double transport_speed() const { return _transport_speed; }
bool transport_stopped() const { return _transport_speed == 0.0f; }
@@ -1074,9 +1075,10 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
nframes_t this_delta, bool starting);
void follow_slave_silently(nframes_t nframes, float slave_speed);
- void set_slave_source (SlaveSource);
+ void use_sync_source (SyncSource);
+ void drop_sync_source ();
- SlaveSource post_export_slave;
+ bool post_export_sync;
nframes_t post_export_position;
bool _exporting;
diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.h
index fd85993a29..2776787271 100644
--- a/libs/ardour/ardour/session_configuration_vars.h
+++ b/libs/ardour/ardour/session_configuration_vars.h
@@ -47,3 +47,5 @@ CONFIG_VARIABLE (bool, use_video_sync, "use-video-sync", false)
CONFIG_VARIABLE (float, video_pullup, "video-pullup", 0.0f)
CONFIG_VARIABLE (bool, show_summary, "show-summary", true)
CONFIG_VARIABLE (bool, show_group_tabs, "show-group-tabs", true)
+CONFIG_VARIABLE (bool, external_sync, "external-sync", false)
+CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", JACK)
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index dd2c8861be..7e09417409 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -360,10 +360,9 @@ namespace ARDOUR {
ExportContext
};
- enum SlaveSource {
- None = 0,
- MTC,
+ enum SyncSource {
JACK,
+ MTC,
MIDIClock
};
@@ -444,7 +443,7 @@ std::istream& operator>>(std::istream& o, ARDOUR::RemoteModel& sf);
std::istream& operator>>(std::istream& o, ARDOUR::ListenPosition& sf);
std::istream& operator>>(std::istream& o, ARDOUR::LayerModel& sf);
std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf);
-std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& sf);
+std::istream& operator>>(std::istream& o, ARDOUR::SyncSource& sf);
std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf);
std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf);
std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf);
@@ -461,7 +460,7 @@ std::ostream& operator<<(std::ostream& o, const ARDOUR::RemoteModel& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ListenPosition& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::LayerModel& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::CrossfadeModel& sf);
-std::ostream& operator<<(std::ostream& o, const ARDOUR::SlaveSource& sf);
+std::ostream& operator<<(std::ostream& o, const ARDOUR::SyncSource& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleBehaviour& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::ShuttleUnits& sf);
std::ostream& operator<<(std::ostream& o, const ARDOUR::TimecodeFormat& sf);
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index c43b7ed37e..6c6f754cf9 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -62,8 +62,8 @@ bool path_is_paired (Glib::ustring path, Glib::ustring& pair_base);
void compute_equal_power_fades (ARDOUR::nframes_t nframes, float* in, float* out);
-const char* slave_source_to_string (ARDOUR::SlaveSource src);
-ARDOUR::SlaveSource string_to_slave_source (std::string str);
+const char* sync_source_to_string (ARDOUR::SyncSource src);
+ARDOUR::SyncSource string_to_sync_source (std::string str);
const char* edit_mode_to_string (ARDOUR::EditMode);
ARDOUR::EditMode string_to_edit_mode (std::string);
diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc
index 885ebeb27a..ed7ba88d8e 100644
--- a/libs/ardour/enums.cc
+++ b/libs/ardour/enums.cc
@@ -70,7 +70,7 @@ setup_enum_writer ()
CDMarkerFormat _CDMarkerFormat;
HeaderFormat _HeaderFormat;
PluginType _PluginType;
- SlaveSource _SlaveSource;
+ SyncSource _SyncSource;
ShuttleBehaviour _ShuttleBehaviour;
ShuttleUnits _ShuttleUnits;
Session::RecordState _Session_RecordState;
@@ -266,11 +266,10 @@ setup_enum_writer ()
REGISTER_ENUM (VST);
REGISTER (_PluginType);
- REGISTER_ENUM (None);
REGISTER_ENUM (MTC);
REGISTER_ENUM (JACK);
REGISTER_ENUM (MIDIClock);
- REGISTER (_SlaveSource);
+ REGISTER (_SyncSource);
REGISTER_ENUM (Sprung);
REGISTER_ENUM (Wheel);
@@ -296,7 +295,7 @@ setup_enum_writer ()
REGISTER_CLASS_ENUM (Session::Event, RangeStop);
REGISTER_CLASS_ENUM (Session::Event, RangeLocate);
REGISTER_CLASS_ENUM (Session::Event, Overwrite);
- REGISTER_CLASS_ENUM (Session::Event, SetSlaveSource);
+ REGISTER_CLASS_ENUM (Session::Event, SetSyncSource);
REGISTER_CLASS_ENUM (Session::Event, Audition);
REGISTER_CLASS_ENUM (Session::Event, InputConfigurationChange);
REGISTER_CLASS_ENUM (Session::Event, SetPlayAudioRange);
@@ -669,15 +668,15 @@ std::ostream& operator<<(std::ostream& o, const CrossfadeModel& var)
std::string s = enum_2_string (var);
return o << s;
}
-std::istream& operator>>(std::istream& o, SlaveSource& var)
+std::istream& operator>>(std::istream& o, SyncSource& var)
{
std::string s;
o >> s;
- var = (SlaveSource) string_2_enum (s, var);
+ var = (SyncSource) string_2_enum (s, var);
return o;
}
-std::ostream& operator<<(std::ostream& o, const SlaveSource& var)
+std::ostream& operator<<(std::ostream& o, const SyncSource& var)
{
std::string s = enum_2_string (var);
return o << s;
diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc
index 4d75c30a0d..8efb72cc8c 100644
--- a/libs/ardour/globals.cc
+++ b/libs/ardour/globals.cc
@@ -126,7 +126,6 @@ int
ARDOUR::setup_midi ()
{
if (Config->midi_ports.size() == 0) {
- //warning << _("no MIDI ports specified: no MMC or MTC control possible") << endmsg;
return 0;
}
@@ -139,27 +138,17 @@ ARDOUR::setup_midi ()
MIDI::Port* first;
const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
+
if (ports.size() > 1) {
first = ports.begin()->second;
/* More than one port, so try using specific names for each port */
- if (Config->get_mmc_port_name() != N_("control")) {
- default_mmc_port = MIDI::Manager::instance()->port (Config->get_mmc_port_name());
- }
-
- if (Config->get_mtc_port_name() != N_("control")) {
- default_mtc_port = MIDI::Manager::instance()->port (Config->get_mtc_port_name());
- }
-
- if (Config->get_midi_port_name() != N_("control")) {
- default_midi_port = MIDI::Manager::instance()->port (Config->get_midi_port_name());
- }
-
- if (Config->get_midi_clock_port_name() != N_("control")) {
- default_midi_port = MIDI::Manager::instance()->port (Config->get_midi_clock_port_name());
- }
+ default_mmc_port = MIDI::Manager::instance()->port (Config->get_mmc_port_name());
+ default_mtc_port = MIDI::Manager::instance()->port (Config->get_mtc_port_name());
+ default_midi_port = MIDI::Manager::instance()->port (Config->get_midi_port_name());
+ default_midi_clock_port = MIDI::Manager::instance()->port (Config->get_midi_clock_port_name());
/* If that didn't work, just use the first listed port */
@@ -194,7 +183,6 @@ ARDOUR::setup_midi ()
if (default_mmc_port == 0) {
warning << string_compose (_("No MMC control (MIDI port \"%1\" not available)"), Config->get_mmc_port_name())
<< endmsg;
- return 0;
}
@@ -339,8 +327,11 @@ ARDOUR::init (bool use_vst, bool try_optimization)
return -1;
}
+
Config->set_use_vst (use_vst);
+ cerr << "After config loaded, MTC port name = " << Config->get_mtc_port_name() << endl;
+
Profile = new RuntimeProfile;
diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc
index f04c148ab7..b34a6fd1ee 100644
--- a/libs/ardour/rc_configuration.cc
+++ b/libs/ardour/rc_configuration.cc
@@ -203,6 +203,8 @@ RCConfiguration::get_state ()
MIDI::Manager::PortMap::const_iterator i;
const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
+ cerr << "Saving " << ports.size() << " MIDI ports\n";
+
for (i = ports.begin(); i != ports.end(); ++i) {
root->add_child_nocopy(i->second->get_state());
}
@@ -260,8 +262,11 @@ RCConfiguration::set_state (const XMLNode& root, int /*version*/)
MIDI::Port::Descriptor desc (*node);
map<string,XMLNode>::iterator x;
+
if ((x = midi_ports.find (desc.tag)) != midi_ports.end()) {
- midi_ports.erase (x);
+ warning << string_compose (_("Duplicate MIDI port definition found (tag=\"%1\") - ignored"),
+ desc.tag) << endmsg;
+ continue;
}
midi_ports.insert (pair<string,XMLNode>(desc.tag,*node));
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 509fb0a999..9d7d32d17e 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4444,3 +4444,21 @@ Session::route_group_changed ()
{
RouteGroupChanged (); /* EMIT SIGNAL */
}
+
+vector<SyncSource>
+Session::get_available_sync_options () const
+{
+ vector<SyncSource> ret;
+
+ ret.push_back (JACK);
+
+ if (mtc_port()) {
+ ret.push_back (MTC);
+ }
+
+ if (midi_clock_port()) {
+ ret.push_back (MIDIClock);
+ }
+
+ return ret;
+}
diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc
index fb993faa68..7304991948 100644
--- a/libs/ardour/session_events.cc
+++ b/libs/ardour/session_events.cc
@@ -393,8 +393,8 @@ Session::process_event (Event* ev)
set_diskstream_speed (static_cast<Diskstream*> (ev->ptr), ev->speed);
break;
- case Event::SetSlaveSource:
- set_slave_source (ev->slave);
+ case Event::SetSyncSource:
+ use_sync_source (ev->sync_source);
break;
case Event::Audition:
diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc
index 0bf87591cd..da18ceb3cb 100644
--- a/libs/ardour/session_export.cc
+++ b/libs/ardour/session_export.cc
@@ -85,10 +85,10 @@ Session::pre_export ()
/* no slaving */
- post_export_slave = Config->get_slave_source ();
+ post_export_sync = config.get_external_sync ();
post_export_position = _transport_frame;
- Config->set_slave_source (None);
+ config.set_external_sync (false);
_exporting = true;
export_status->running = true;
@@ -244,8 +244,8 @@ Session::finalize_audio_export ()
/* restart slaving */
- if (post_export_slave != None) {
- Config->set_slave_source (post_export_slave);
+ if (post_export_sync) {
+ config.set_external_sync (true);
} else {
locate (post_export_position, false, false, false);
}
diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc
index f7ee8ef3c9..34d9b470f5 100644
--- a/libs/ardour/session_midi.cc
+++ b/libs/ardour/session_midi.cc
@@ -141,6 +141,8 @@ Session::set_mtc_port (string port_tag)
ms->rebind (*port);
}
+ cerr << "!!SPT to " << port_tag << endl;
+
Config->set_mtc_port_name (port_tag);
out:
@@ -494,7 +496,7 @@ Session::setup_midi_control ()
void
Session::spp_start (Parser &, nframes_t /*timestamp*/)
{
- if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
+ if (Config->get_mmc_control() && (config.get_external_sync() && config.get_sync_source() != MTC)) {
request_transport_speed (1.0);
}
}
@@ -516,7 +518,7 @@ Session::spp_stop (Parser&, nframes_t /*timestamp*/)
void
Session::midi_clock_start (Parser& ignored, nframes_t timestamp)
{
- if (Config->get_slave_source() == MIDIClock) {
+ if (config.get_external_sync() && (config.get_sync_source() == MIDIClock)) {
request_transport_speed (1.0);
}
}
@@ -530,7 +532,7 @@ Session::midi_clock_continue (Parser& parser, nframes_t timestamp)
void
Session::midi_clock_stop (Parser& ignored, nframes_t timestamp)
{
- if (Config->get_slave_source() == MIDIClock) {
+ if (config.get_external_sync() && (config.get_slave_source() == MIDIClock)) {
request_stop ();
}
}
@@ -539,7 +541,7 @@ Session::midi_clock_stop (Parser& ignored, nframes_t timestamp)
void
Session::mmc_deferred_play (MIDI::MachineControl &/*mmc*/)
{
- if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
+ if (Config->get_mmc_control() && (config.get_external_sync() && (config.get_sync_source() != MTC))) {
request_transport_speed (1.0);
}
}
diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc
index 4bbe852687..a79a2e4cd8 100644
--- a/libs/ardour/session_process.cc
+++ b/libs/ardour/session_process.cc
@@ -469,7 +469,7 @@ Session::transport_locked () const
{
Slave* sl = _slave;
- if (!locate_pending() && ((Config->get_slave_source() == None) || (sl && sl->ok() && sl->locked()))) {
+ if (!locate_pending() && (!config.get_external_sync() || (sl && sl->ok() && sl->locked()))) {
return true;
}
@@ -487,7 +487,7 @@ Session::follow_slave (nframes_t nframes)
if (!_slave->ok()) {
stop_transport ();
- Config->set_slave_source (None);
+ config.set_external_sync (false);
goto noroll;
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 1a4758186e..2e564b7eee 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -215,6 +215,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
destructive_index = 0;
first_file_data_format_reset = true;
first_file_header_format_reset = true;
+ post_export_sync = false;
//midi_thread = (pthread_t) 0;
AudioDiskstream::allocate_working_buffers();
@@ -869,15 +870,7 @@ int
Session::load_options (const XMLNode& node)
{
LocaleGuard lg (X_("POSIX"));
-
config.set_variables (node);
-
- /* now reset MIDI ports because the session can have its own
- MIDI configuration.
- */
-
- setup_midi ();
-
return 0;
}
@@ -3200,8 +3193,12 @@ Session::config_changed (std::string p, bool ours)
first_file_data_format_reset = false;
- } else if (p == "slave-source") {
- set_slave_source (Config->get_slave_source());
+ } else if (p == "external-sync") {
+ if (!config.get_external_sync()) {
+ drop_sync_source ();
+ } else {
+ use_sync_source (config.get_sync_source());
+ }
} else if (p == "remote-model") {
set_remote_control_ids ();
} else if (p == "denormal-model") {
diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc
index 10429e9639..b7377d7dc6 100644
--- a/libs/ardour/session_transport.cc
+++ b/libs/ardour/session_transport.cc
@@ -79,9 +79,9 @@ Session::request_input_change_handling ()
}
void
-Session::request_slave_source (SlaveSource src)
+Session::request_sync_source (SyncSource src)
{
- Event* ev = new Event (Event::SetSlaveSource, Event::Add, Event::Immediate, 0, 0.0);
+ Event* ev = new Event (Event::SetSyncSource, Event::Add, Event::Immediate, 0, 0.0);
bool seamless;
seamless = Config->get_seamless_loop ();
@@ -97,7 +97,7 @@ Session::request_slave_source (SlaveSource src)
/* save value of seamless from before the switch */
_was_seamless = seamless;
- ev->slave = src;
+ ev->sync_source = src;
queue_event (ev);
}
@@ -230,7 +230,7 @@ Session::realtime_stop (bool abort, bool clear_state)
waiting_for_sync_offset = true;
}
- transport_sub_state = ((Config->get_slave_source() == None && config.get_auto_return()) ? AutoReturning : 0);
+ transport_sub_state = ((!config.get_external_sync()&& config.get_auto_return()) ? AutoReturning : 0);
}
void
@@ -439,7 +439,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
}
bool const auto_return_enabled =
- (Config->get_slave_source() == None && config.get_auto_return());
+ (!config.get_external_sync() && config.get_auto_return());
if (auto_return_enabled ||
(ptw & PostTransportLocate) ||
@@ -571,7 +571,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
/* and start it up again if relevant */
- if ((ptw & PostTransportLocate) && Config->get_slave_source() == None && pending_locate_roll) {
+ if ((ptw & PostTransportLocate) && !config.get_external_sync() && pending_locate_roll) {
request_transport_speed (1.0);
pending_locate_roll = false;
}
@@ -1106,7 +1106,7 @@ Session::post_transport ()
if (ptw & PostTransportLocate) {
- if (((Config->get_slave_source() == None && (auto_play_legal && config.get_auto_play())) && !_exporting) || (ptw & PostTransportRoll)) {
+ if (((!config.get_external_sync() && (auto_play_legal && config.get_auto_play())) && !_exporting) || (ptw & PostTransportRoll)) {
start_transport ();
} else {
@@ -1142,9 +1142,8 @@ Session::reset_rf_scale (nframes_t motion)
}
void
-Session::set_slave_source (SlaveSource src)
+Session::drop_sync_source ()
{
- bool reverse = false;
bool non_rt_required = false;
if (_transport_speed) {
@@ -1152,22 +1151,42 @@ Session::set_slave_source (SlaveSource src)
return;
}
-// if (src == JACK && Config->get_jack_time_master()) {
-// return;
-// }
-
delete _slave;
_slave = 0;
- if (_transport_speed < 0.0) {
- reverse = true;
+ boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader();
+ for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
+ if (!(*i)->hidden()) {
+ if ((*i)->realtime_set_speed ((*i)->speed(), true)) {
+ non_rt_required = true;
+ }
+ (*i)->set_slaved (0);
+ }
}
- switch (src) {
- case None:
- stop_transport ();
- break;
+ if (non_rt_required) {
+ add_post_transport_work (PostTransportSpeed);
+ _butler->schedule_transport_work ();
+ }
+ set_dirty();
+}
+
+void
+Session::use_sync_source (SyncSource src)
+{
+ bool reverse = false;
+ bool non_rt_required = false;
+
+ if (_transport_speed) {
+ error << _("please stop the transport before adjusting slave settings") << endmsg;
+ return;
+ }
+
+ delete _slave;
+ _slave = 0;
+
+ switch (src) {
case MTC:
if (_mtc_port) {
try {
@@ -1206,8 +1225,6 @@ Session::set_slave_source (SlaveSource src)
};
- Config->set_slave_source (src);
-
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader();
for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
if (!(*i)->hidden()) {
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index abed926983..af90c935c9 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -331,14 +331,10 @@ edit_mode_to_string (EditMode mode)
}
}
-SlaveSource
-string_to_slave_source (string str)
+SyncSource
+string_to_sync_source (string str)
{
- if (str == _("Internal")) {
- return None;
- }
-
- if (str == _("MTC")) {
+ if (str == _("MIDI Timecode")) {
return MTC;
}
@@ -350,29 +346,26 @@ string_to_slave_source (string str)
return JACK;
}
- fatal << string_compose (_("programming error: unknown slave source string \"%1\""), str) << endmsg;
+ fatal << string_compose (_("programming error: unknown sync source string \"%1\""), str) << endmsg;
/*NOTREACHED*/
- return None;
+ return JACK;
}
const char*
-slave_source_to_string (SlaveSource src)
+sync_source_to_string (SyncSource src)
{
switch (src) {
case JACK:
return _("JACK");
case MTC:
- return _("MTC");
+ return _("MIDI Timecode");
case MIDIClock:
return _("MIDI Clock");
-
- default:
- case None:
- return _("Internal");
-
}
+ /* GRRRR .... stupid, stupid gcc - you can't get here from there, all enum values are handled */
+ return _("JACK");
}
float
diff --git a/libs/midi++2/factory.cc b/libs/midi++2/factory.cc
index 1980ac508b..40cadd2390 100644
--- a/libs/midi++2/factory.cc
+++ b/libs/midi++2/factory.cc
@@ -110,6 +110,12 @@ PortFactory::ignore_duplicate_devices (Port::Type type)
break;
#endif // WITH_ALSA
+#ifdef WITH_JACK_MIDI
+ case Port::JACK_Midi:
+ ret = true;
+ break;
+#endif // WITH_JACK_MIDI
+
#if WITH_COREMIDI
case Port::CoreMidi_MidiPort:
ret = true;
diff --git a/libs/midi++2/manager.cc b/libs/midi++2/manager.cc
index ab03688e49..ab37073afd 100644
--- a/libs/midi++2/manager.cc
+++ b/libs/midi++2/manager.cc
@@ -70,12 +70,6 @@ Manager::add_port (const XMLNode& node)
PortMap::iterator existing;
pair<string, Port *> newpair;
- /* do not allow multiple ports with the same tag. if attempted, just return the existing
- port with the same tag. XXX this is really caused by the mess of setup_midi() being
- called twice in Ardour, once in the global init() function and once after the user RC file
- has been loaded (there may be extra ports in it).
- */
-
if ((existing = ports_by_tag.find (desc.tag)) != ports_by_tag.end()) {
port = (*existing).second;
@@ -150,6 +144,7 @@ Manager::add_port (const XMLNode& node)
}
port = factory.create_port (node, api_data);
+
if (port == 0) {
return 0;
diff --git a/libs/midi++2/wscript b/libs/midi++2/wscript
index 14974581a9..735d513179 100644
--- a/libs/midi++2/wscript
+++ b/libs/midi++2/wscript
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import autowaf
import os
+import sys
# Version of this package (even if built as a child)
MAJOR = '2'
@@ -36,10 +37,6 @@ def configure(conf):
autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
- # TODO
- conf.env['SYSMIDI'] = 'JACK MIDI'
- conf.env.append_value('CXXFLAGS', '-DWITH_JACK_MIDI')
-
# Boost headers
autowaf.check_header(conf, 'boost/shared_ptr.hpp')
autowaf.check_header(conf, 'boost/weak_ptr.hpp')
@@ -61,12 +58,17 @@ def build(bld):
mtc.cc
version.cc
'''
- if bld.env['SYSMIDI'] == 'JACK MIDI':
- obj.source += ' jack_midiport.cc '
- elif bld.env['SYSMIDI'] == 'Alsa Sequencer':
- obj.source += ' alsa_sequencer_midiport.cc '
- elif bld.env['SYSMIDI'] == 'CoreMIDI':
+ # everybody loves JACK
+ obj.source += ' jack_midiport.cc '
+ obj.cxxflags = [ '-DWITH_JACK_MIDI' ]
+ if sys.platform == 'darwin':
+ # OS X
obj.source += ' coremidi_midiport.cc '
+ obj.cxxflags += [ '-DWITH_COREMIDI' ]
+ else :
+ # linux
+ obj.source += ' alsa_sequencer_midiport.cc '
+ obj.cxxflags += [ '-DWITH_ALSA' ]
obj.export_incdirs = ['.']
obj.includes = ['.']
obj.name = 'libmidipp'
diff --git a/wscript b/wscript
index fec8a11d05..41976d9627 100644
--- a/wscript
+++ b/wscript
@@ -529,12 +529,23 @@ def build(bld):
bld.add_subdirs('libs/appleutility')
for i in children:
bld.add_subdirs(i)
+
+ # ideally, we'd like to use the OS-provided MIDI API
+ # for default ports. that doesn't work on at least
+ # Fedora (Nov 9th, 2009) so use JACK MIDI on linux.
- rc_subst_dict = {
- 'MIDITAG' : 'control',
- 'MIDITYPE' : 'jack',
- 'JACK_INPUT' : 'auditioner'
- }
+ if sys.platform == 'darwin':
+ rc_subst_dict = {
+ 'MIDITAG' : 'control',
+ 'MIDITYPE' : 'coremidi',
+ 'JACK_INPUT' : 'auditioner'
+ }
+ else:
+ rc_subst_dict = {
+ 'MIDITAG' : 'control',
+ 'MIDITYPE' : 'jack',
+ 'JACK_INPUT' : 'auditioner'
+ }
obj = bld.new_task_gen('subst')
obj.source = 'ardour.rc.in'