diff options
author | Robin Gareus <robin@gareus.org> | 2014-06-26 19:07:38 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-06-26 19:16:20 +0200 |
commit | 789cf92a23d6c6d96d3b7f5f410502c88a547c13 (patch) | |
tree | 091dfa474e70efa3ea68e2fd5f6f48ff37793025 | |
parent | a74d7bd232c1b97a05be478c4389aa434470bb60 (diff) |
bump take-name after every recording
-rw-r--r-- | libs/ardour/ardour/utils.h | 1 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 5 | ||||
-rw-r--r-- | libs/ardour/utils.cc | 25 |
3 files changed, 31 insertions, 0 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 05fb2446a9..4b71c1586e 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -58,6 +58,7 @@ static inline float f_max(float x, float a) { } LIBARDOUR_API std::string bump_name_once(const std::string& s, char delimiter); +LIBARDOUR_API std::string bump_name_number(const std::string& s); LIBARDOUR_API int cmp_nocase (const std::string& s, const std::string& s2); LIBARDOUR_API int cmp_nocase_utf8 (const std::string& s1, const std::string& s2); diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 05233c030a..85b36e5a66 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -534,6 +534,11 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) if (did_record) { commit_reversible_command (); + /* increase take name */ + if (config.get_track_name_take () && !config.get_take_name ().empty()) { + string newname = config.get_take_name(); + config.set_take_name(bump_name_number (newname)); + } } if (_engine.running()) { diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index d4b0a77893..6fdab19497 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -196,6 +196,31 @@ ARDOUR::bump_name_once (const std::string& name, char delimiter) } +string +ARDOUR::bump_name_number (const std::string& name) +{ + size_t pos = name.length(); + bool have_number = false; + while (pos > 0 && isdigit(name.at(--pos))) { + have_number = true; + } + + string newname; + if (have_number) { + ++pos; + int32_t num = strtol (name.c_str() + pos, (char **)NULL, 10); + char buf[32]; + snprintf (buf, sizeof(buf), "%d", num + 1); + newname = name.substr (0, pos); + newname += buf; + } else { + newname = name; + newname += "1"; + } + + return newname; +} + XMLNode * ARDOUR::find_named_node (const XMLNode& node, string name) { |