13
0

option to use track-number and take-name as part of file-name

This commit is contained in:
Robin Gareus 2014-06-26 19:16:07 +02:00
parent b067a185f0
commit a74d7bd232
3 changed files with 55 additions and 1 deletions

View File

@ -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)

View File

@ -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*/

View File

@ -68,6 +68,8 @@ 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;
}
@ -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<Track> me = boost::dynamic_pointer_cast<Track> (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