13
0

Allow user to choose the session time-domain

This commit is contained in:
Ben Loftis 2023-09-14 12:36:10 -05:00 committed by Robin Gareus
parent d7345d7d4d
commit 4bed642d71
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 68 additions and 33 deletions

View File

@ -227,7 +227,7 @@ public:
int copy_demo_sessions ();
int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
bool session_load_in_progress;
int build_session (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool from_startup_fsm, bool unnamed);
int build_session (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool from_startup_fsm, bool unnamed, Temporal::TimeDomain domain);
bool session_is_new() const { return _session_is_new; }
ARDOUR::Session* the_session() { return _session; }
@ -239,7 +239,7 @@ public:
void start_session_load (bool create_new);
void session_dialog_response_handler (int response, SessionDialog* session_dialog);
void build_session_from_dialog (SessionDialog&, std::string const& session_name, std::string const& session_path, std::string const& session_template);
void build_session_from_dialog (SessionDialog&, std::string const& session_name, std::string const& session_path, std::string const& session_template, Temporal::TimeDomain domain);
bool ask_about_loading_existing_session (const std::string& session_path);
int load_session_from_startup_fsm ();
@ -473,8 +473,8 @@ private:
void audio_midi_setup_reconfigure_done (int response, std::string path, std::string snapshot, std::string mix_template);
int load_session_stage_two (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
void audio_midi_setup_for_new_session_done (int response, std::string path, std::string snapshot, std::string session_template, ARDOUR::BusProfile const&, bool unnamed);
int build_session_stage_two (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool unnamed);
void audio_midi_setup_for_new_session_done (int response, std::string path, std::string snapshot, std::string session_template, ARDOUR::BusProfile const&, bool unnamed, Temporal::TimeDomain domain);
int build_session_stage_two (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool unnamed, Temporal::TimeDomain domain);
sigc::connection _engine_dialog_connection;
void save_session_at_its_request (std::string);

View File

@ -112,20 +112,19 @@ ARDOUR_UI::ask_about_loading_existing_session (const std::string& session_path)
}
void
ARDOUR_UI::build_session_from_dialog (SessionDialog& sd, const std::string& session_path, const std::string& session_name, std::string const& session_template)
ARDOUR_UI::build_session_from_dialog (SessionDialog& sd, const std::string& session_path, const std::string& session_name, std::string const& session_template, Temporal::TimeDomain domain)
{
BusProfile bus_profile;
if (nsm) {
bus_profile.master_out_channels = 2;
} else if ( Profile->get_mixbus()) {
} else if (Profile->get_mixbus ()) {
bus_profile.master_out_channels = 2;
} else {
/* get settings from advanced section of NSD */
bus_profile.master_out_channels = (uint32_t) sd.master_channel_count();
}
build_session (session_path, session_name, session_template, bus_profile, false, !sd.was_new_name_edited());
}
/** This is only ever used once Ardour is already running with a session
@ -161,6 +160,7 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session
string session_name;
string session_path;
string template_name;
Temporal::TimeDomain session_domain;
bool likely_new = false;
session_path = "";
@ -175,6 +175,7 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session
session_name = session_dialog->session_name (likely_new);
session_path = session_dialog->session_folder ();
session_domain = session_dialog->session_domain ();
if (nsm) {
likely_new = true;
@ -289,7 +290,7 @@ ARDOUR_UI::session_dialog_response_handler (int response, SessionDialog* session
if (!template_name.empty() || likely_new) {
build_session_from_dialog (*session_dialog, session_path, session_name, template_name);
build_session_from_dialog (*session_dialog, session_path, session_name, template_name, session_domain);
} else {
@ -604,7 +605,7 @@ ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& s
}
int
ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name, const std::string& session_template, BusProfile const& bus_profile, bool from_startup_fsm, bool unnamed)
ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name, const std::string& session_template, BusProfile const& bus_profile, bool from_startup_fsm, bool unnamed, Temporal::TimeDomain domain)
{
int x;
@ -623,11 +624,11 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
* asked for the SR (even if try-autostart-engine is set)
*/
if (from_startup_fsm && AudioEngine::instance()->running ()) {
return build_session_stage_two (path, snap_name, session_template, bus_profile, unnamed);
return build_session_stage_two (path, snap_name, session_template, bus_profile, unnamed, domain);
}
/* Sample-rate cannot be changed when JACK is running */
if (!ARDOUR::AudioEngine::instance()->setup_required () && AudioEngine::instance()->running ()) {
return build_session_stage_two (path, snap_name, session_template, bus_profile, unnamed);
return build_session_stage_two (path, snap_name, session_template, bus_profile, unnamed, domain);
}
/* Work-around missing "OK" button:
@ -643,7 +644,7 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
audio_midi_setup->set_position (WIN_POS_CENTER);
audio_midi_setup->set_modal ();
audio_midi_setup->present ();
_engine_dialog_connection = audio_midi_setup->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::audio_midi_setup_for_new_session_done), path, snap_name, session_template, bus_profile, unnamed));
_engine_dialog_connection = audio_midi_setup->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::audio_midi_setup_for_new_session_done), path, snap_name, session_template, bus_profile, unnamed, domain));
/* not done yet, but we're avoiding modal dialogs */
return 0;
@ -651,7 +652,7 @@ ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name,
void
ARDOUR_UI::audio_midi_setup_for_new_session_done (int response, std::string path, std::string snap_name, std::string template_name, BusProfile const& bus_profile, bool unnamed)
ARDOUR_UI::audio_midi_setup_for_new_session_done (int response, std::string path, std::string snap_name, std::string template_name, BusProfile const& bus_profile, bool unnamed, Temporal::TimeDomain domain)
{
_engine_dialog_connection.disconnect ();
@ -669,11 +670,11 @@ ARDOUR_UI::audio_midi_setup_for_new_session_done (int response, std::string path
audio_midi_setup->set_modal (false);
audio_midi_setup->hide();
build_session_stage_two (path, snap_name, template_name, bus_profile, unnamed);
build_session_stage_two (path, snap_name, template_name, bus_profile, unnamed, domain);
}
int
ARDOUR_UI::build_session_stage_two (std::string const& path, std::string const& snap_name, std::string const& session_template, BusProfile const& bus_profile, bool unnamed)
ARDOUR_UI::build_session_stage_two (std::string const& path, std::string const& snap_name, std::string const& session_template, BusProfile const& bus_profile, bool unnamed, Temporal::TimeDomain domain)
{
Session* new_session;
@ -774,6 +775,8 @@ ARDOUR_UI::build_session_stage_two (std::string const& path, std::string const&
n->set_property (X_("left-frame"), X_("0"));
}
new_session->config.set_default_time_domain(domain);
set_session (new_session);
new_session->save_state(new_session->name());

View File

@ -78,13 +78,13 @@
#include "pbd/i18n.h"
using namespace Temporal;
using namespace ARDOUR;
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace std;
static bool
_hide_splash (gpointer arg)
{
@ -676,16 +676,17 @@ ARDOUR_UI::copy_demo_sessions ()
int
ARDOUR_UI::load_session_from_startup_fsm ()
{
const string session_path = startup_fsm->session_path;
const string session_name = startup_fsm->session_name;
const string session_template = startup_fsm->session_template;
const bool session_is_new = startup_fsm->session_is_new;
const BusProfile bus_profile = startup_fsm->bus_profile;
const bool session_was_not_named = (!startup_fsm->session_name_edited && ARDOUR_COMMAND_LINE::session_name.empty());
const string session_path = startup_fsm->session_path;
const string session_name = startup_fsm->session_name;
const string session_template = startup_fsm->session_template;
const bool session_is_new = startup_fsm->session_is_new;
const bool session_was_not_named = (!startup_fsm->session_name_edited && ARDOUR_COMMAND_LINE::session_name.empty());
const TimeDomain session_domain = startup_fsm->session_domain;
const BusProfile bus_profile = startup_fsm->bus_profile;
if (session_is_new) {
if (build_session (session_path, session_name, session_template, bus_profile, true, session_was_not_named)) {
if (build_session (session_path, session_name, session_template, bus_profile, true, session_was_not_named, session_domain)) {
return -1;
}
return 0;
@ -886,7 +887,7 @@ ARDOUR_UI::load_from_application_api (const std::string& path)
if (nsm) {
BusProfile bus_profile;
bus_profile.master_out_channels = 2;
build_session (path, basename_nosuffix (path), "", bus_profile, true, false);
build_session (path, basename_nosuffix (path), "", bus_profile, true, false, AudioTime);
}
return;
}

View File

@ -343,6 +343,12 @@ SessionDialog::session_folder ()
}
}
Temporal::TimeDomain
SessionDialog::session_domain () const
{
return timebase_chooser.get_active_row_number() == 1 ? Temporal::BeatTime : Temporal::AudioTime;
}
void
SessionDialog::setup_recent_sessions ()
{
@ -660,6 +666,22 @@ SessionDialog::setup_new_session_page ()
new_folder_chooser.set_title (_("Select folder for session"));
Gtkmm2ext::add_volume_shortcuts (new_folder_chooser);
//Timebase for the new session
Label* session_domain_label = manage (new Label);
session_domain_label->set_text (_("Default Time Domain:"));
HBox* timebase_box = manage (new HBox);
timebase_box->set_spacing (8);
timebase_box->pack_start (*session_domain_label, false, false);
timebase_box->pack_start (timebase_chooser, true, true);
timebase_chooser.append (_("Audio Time"));
timebase_chooser.append (_("Beat Time"));
#ifdef MIXBUS
timebase_chooser.set_active (1);
#else
timebase_chooser.set_active (0);
#endif
//Template & Template Description area
HBox* template_hbox = manage (new HBox);
@ -706,6 +728,7 @@ SessionDialog::setup_new_session_page ()
session_new_vbox.pack_start (*template_hbox, true, true);
session_new_vbox.pack_start (*folder_box, false, true);
session_new_vbox.pack_start (*timebase_box, false, true);
session_new_vbox.pack_start (*name_hbox, false, true);
session_new_vbox.show_all ();
}

View File

@ -41,6 +41,8 @@
#include <gtkmm/liststore.h>
#include <gtkmm/combobox.h>
#include "temporal/domain_provider.h"
#include "ardour/utils.h"
#include "ardour_dialog.h"
@ -58,6 +60,8 @@ public:
std::string session_name (bool& should_be_new);
std::string session_folder ();
Temporal::TimeDomain session_domain () const;
bool use_session_template() const;
std::string session_template_name();
@ -77,6 +81,8 @@ private:
Gtk::Button* back_button;
Gtk::Button* quit_button;
Gtk::ComboBoxText timebase_chooser;
bool back_button_pressed (GdkEventButton*);
bool open_button_pressed (GdkEventButton*);

View File

@ -705,8 +705,9 @@ StartupFSM::check_session_parameters (bool must_be_new)
{
bool requested_new = false;
session_name = session_dialog->session_name (requested_new);
session_path = session_dialog->session_folder ();
session_name = session_dialog->session_name (requested_new);
session_path = session_dialog->session_folder ();
session_domain = session_dialog->session_domain ();
session_name_edited = session_dialog->was_new_name_edited ();
if (must_be_new) {

View File

@ -63,13 +63,14 @@ class StartupFSM : public sigc::trackable
void start ();
void reset ();
std::string session_path;
std::string session_name;
std::string session_template;
int session_existing_sample_rate;
XMLNode session_engine_hints;
bool session_is_new;
bool session_name_edited;
std::string session_path;
std::string session_name;
std::string session_template;
Temporal::TimeDomain session_domain;
int session_existing_sample_rate;
XMLNode session_engine_hints;
bool session_is_new;
bool session_name_edited;
ARDOUR::BusProfile bus_profile;