From 2cb3cbe491b2a0782968b53e04c781dd1fcc9b04 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 28 May 2015 19:08:47 -0400 Subject: [PATCH] change the semantics of AudioFileSource::peak_path() and Session::peak_path() a little. If given a full path that points outside the current session but is within another ardour session, attempt to use the peakfiles present in that other session. --- libs/ardour/audiofilesource.cc | 13 +++++++++++- libs/ardour/session.cc | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 2523a85b1a..19434bd145 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -168,10 +168,21 @@ AudioFileSource::peak_path (string audio_path) { string base; - base = PBD::basename_nosuffix (audio_path); + string::size_type suffix = audio_path.find_last_of ('.'); + + if (suffix != string::npos) { + base = audio_path.substr (0, suffix); + } else { + warning << string_compose (_("Odd audio file path: %1"), audio_path) << endmsg; + base = audio_path; + } + base += '%'; base += (char) ('A' + _channel); + /* pass in the name/path of the source, with no audio file type suffix + */ + return _session.peak_path (base); } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 6045c940a9..30c1d2acdd 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -66,6 +66,7 @@ #include "ardour/control_protocol_manager.h" #include "ardour/data_type.h" #include "ardour/debug.h" +#include "ardour/directory_names.h" #include "ardour/filename_extensions.h" #include "ardour/graph.h" #include "ardour/midiport_manager.h" @@ -3745,6 +3746,41 @@ Session::count_sources_by_origin (const string& path) string Session::peak_path (string base) const { + if (Glib::path_is_absolute (base)) { + + /* rip the session dir from the audiofile source */ + + string session_path; + string interchange_dir_string = string (interchange_dir_name) + G_DIR_SEPARATOR; + bool in_another_session = true; + + if (base.find (interchange_dir_string) != string::npos) { + + session_path = Glib::path_get_dirname (base); /* now ends in audiofiles */ + session_path = Glib::path_get_dirname (session_path); /* now ends in session name */ + session_path = Glib::path_get_dirname (session_path); /* now ends in interchange */ + session_path = Glib::path_get_dirname (session_path); /* now has session path */ + + /* see if it is within our session */ + + for (vector::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) { + if (i->path == session_path) { + in_another_session = false; + break; + } + } + } else { + in_another_session = false; + } + + + if (in_another_session) { + SessionDirectory sd (session_path); + return Glib::build_filename (sd.peak_path(), Glib::path_get_basename (base) + peakfile_suffix); + } + } + + base = Glib::path_get_basename (base); return Glib::build_filename (_session_dir->peak_path(), base + peakfile_suffix); } -- 2.30.2