mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-30 18:37:40 +01:00
bump take-name after every recording
This commit is contained in:
parent
17195c7167
commit
b7ff8a1fe8
3 changed files with 31 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue