diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index dc301132d6..b08ecb42a6 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -110,8 +110,26 @@ public: bool set_name (const std::string& str); void set_region_ownership (); - std::string pgroup_id() { return _pgroup_id; } - void set_pgroup_id(std::string pgid) { _pgroup_id = pgid; PropertyChanged (Properties::name); } + /*playlist group IDs (pgroup_id) is a group identifier that is implicitly + * or explicitly assigned to playlists so they can be associated with each other. + * + * For example, when you switch a track's playlist, you can choose to + * switch other tracks to the same pgroup_id + * + * pgroup_id's should be unique; currently we use a timestamp to avoid duplicates. + * pgroup_id's are human-readable strings; use string comparison to find matches. + * + * To be useful, we want every playlist to be assigned a sensible pgroup_id + * Some examples of pgroup_id's getting assigned *explicitly* include: + * when the user makes a new playlist for a track or Track Group + * when the user triggers an action like "new playlist for rec-armed tracks" + * Some examples of pgroup_id's getting assigned *implicitly* include: + * the user makes the first recording pass ("take") in an empty playlist + * the user imports tracks. + */ + static std::string generate_pgroup_id(); + std::string pgroup_id() { return _pgroup_id; } + void set_pgroup_id(std::string pgid) { _pgroup_id = pgid; PropertyChanged (Properties::name); } virtual void clear (bool with_signals = true); virtual void dump () const; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 49d5f2c619..39c1bbdf29 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -30,6 +30,8 @@ #include #include +#include + #include "pbd/stateful_diff_command.h" #include "pbd/strsplit.h" #include "pbd/types_convert.h" @@ -2240,6 +2242,17 @@ Playlist::clear_owned_changes () Stateful::clear_owned_changes (); } +string +Playlist::generate_pgroup_id () +{ + time_t now; + time (&now); + Glib::DateTime tm (Glib::DateTime::create_now_local (now)); + string gid; + gid = (tm.format ("%F %H.%M.%S")); + return gid; +} + void Playlist::update (const RegionListProperty::ChangeRecord& change) {