From a74d7bd232c1b97a05be478c4389aa434470bb60 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 26 Jun 2014 19:16:07 +0200 Subject: [PATCH] option to use track-number and take-name as part of file-name --- .../ardour/session_configuration_vars.h | 3 ++ libs/ardour/ardour/track.h | 4 ++ libs/ardour/track.cc | 49 ++++++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.h index 6349692e77..f62816f3a7 100644 --- a/libs/ardour/ardour/session_configuration_vars.h +++ b/libs/ardour/ardour/session_configuration_vars.h @@ -41,6 +41,9 @@ CONFIG_VARIABLE (Timecode::TimecodeFormat, timecode_format, "timecode-format", T CONFIG_VARIABLE_SPECIAL(std::string, raid_path, "raid-path", "", PBD::path_expand) CONFIG_VARIABLE_SPECIAL(std::string, audio_search_path, "audio-search-path", "", PBD::search_path_expand) CONFIG_VARIABLE_SPECIAL(std::string, midi_search_path, "midi-search-path", "", PBD::search_path_expand) +CONFIG_VARIABLE (bool, track_name_number, "track-name-number", false) +CONFIG_VARIABLE (bool, track_name_take, "track-name-take", false) +CONFIG_VARIABLE (std::string, take_name, "take-name", "Take") CONFIG_VARIABLE (bool, jack_time_master, "jack-time-master", true) CONFIG_VARIABLE (bool, use_video_sync, "use-video-sync", false) CONFIG_VARIABLE (float, video_pullup, "video-pullup", 0.0f) diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 736ca8c6dd..d33e24e4e6 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -44,6 +44,7 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream int init (); bool set_name (const std::string& str); + void resync_track_name (); TrackMode mode () const { return _mode; } virtual int set_mode (TrackMode /*m*/) { return false; } @@ -228,6 +229,9 @@ private: void diskstream_record_enable_changed (); void diskstream_speed_changed (); void diskstream_alignment_style_changed (); + void parameter_changed (std::string const & p); + + std::string _diskstream_name; }; }; /* namespace ARDOUR*/ diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 5c95de0c41..d463be598f 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -68,8 +68,10 @@ Track::init () /* don't add rec_enable_control to controls because we don't want it to * appear as an automatable parameter */ + track_number_changed.connect_same_thread (*this, boost::bind (&Track::resync_track_name, this)); + _session.config.ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1)); - return 0; + return 0; } void @@ -284,6 +286,28 @@ Track::set_record_enabled (bool yn, void *src) _rec_enable_control->Changed (); } +void +Track::parameter_changed (string const & p) +{ + if (p == "track-name-number") { + resync_track_name (); + } + else if (p == "track-name-take") { + resync_track_name (); + } + else if (p == "take-name") { + if (_session.config.get_track_name_take()) { + resync_track_name (); + } + } +} + +void +Track::resync_track_name () +{ + set_name(name()); +} + bool Track::set_name (const string& str) { @@ -294,6 +318,29 @@ Track::set_name (const string& str) return false; } + string diskstream_name = ""; + if (_session.config.get_track_name_take () && !_session.config.get_take_name ().empty()) { + // Note: any text is fine, legalize_for_path() fixes this later + diskstream_name += _session.config.get_take_name (); + diskstream_name += "_"; + } + const int64_t tracknumber = track_number(); + if (tracknumber > 0 && _session.config.get_track_name_number()) { + char num[64], fmt[10]; + snprintf(fmt, sizeof(fmt), "%%0%d" PRId64, _session.track_number_decimals()); + snprintf(num, sizeof(num), fmt, tracknumber); + diskstream_name += num; + diskstream_name += "_"; + } + diskstream_name += str; + + if (diskstream_name == _diskstream_name) { + return true; + } + _diskstream_name = diskstream_name; + + _diskstream->set_write_source_name (diskstream_name); + boost::shared_ptr me = boost::dynamic_pointer_cast (shared_from_this ()); if (_diskstream->playlist()->all_regions_empty () && _session.playlists->playlists_for_track (me).size() == 1) { /* Only rename the diskstream (and therefore the playlist) if