ToobAmp: correctlly map default file property for Toob Convolution Reverb.

This commit is contained in:
Robin E. R. Davies
2025-02-20 12:40:38 -05:00
parent 7f0ef66877
commit d182efbc93
28 changed files with 116 additions and 48 deletions
+38 -1
View File
@@ -50,6 +50,7 @@
#endif /* NO_MLOCK */
using namespace pipedal;
namespace fs = std::filesystem;
template <typename T>
T &constMutex(const T &mutex)
@@ -2309,10 +2310,46 @@ void PiPedalModel::SetSystemMidiBindings(std::vector<MidiBinding> &bindings)
}
}
FileRequestResult PiPedalModel::GetFileList2(const std::string &relativePath, const UiFileProperty &fileProperty)
PedalboardItem*PiPedalModel::GetPedalboardItemForFileProperty(const UiFileProperty& fileProperty)
{
for (PedalboardItem*pedalboardItem: this->pedalboard.GetAllPlugins())
{
if (pedalboardItem->pathProperties_.contains(fileProperty.patchProperty()))
{
return pedalboardItem;
}
}
return nullptr;
}
FileRequestResult PiPedalModel::GetFileList2(const std::string &relativePath_, const UiFileProperty &fileProperty)
{
std::string relativePath = relativePath_;
try
{
if (!storage.IsInUploadsDirectory(relativePath))
{
// if relativePath is in a resource directory of the plugin, then we have loaded a factory preset or are using a default property.
// map the resource path to the corresponding file in the uploads directory.
// :-(
PedalboardItem *pedalboardItem = GetPedalboardItemForFileProperty(fileProperty);
if (pedalboardItem)
{
auto pluginInfo = GetPluginInfo(pedalboardItem->uri());
if (pluginInfo) {
std::filesystem::path resourcePath = fs::path(pluginInfo->bundle_path())
/ fileProperty.resourceDirectory();
if (IsSubdirectory(relativePath,resourcePath))
{
fs::path t = MakeRelativePath(relativePath,resourcePath);
t = fileProperty.directory() / t;
if (fs::exists(t))
{
relativePath = t;
}
}
}
}
}
return this->storage.GetFileList2(relativePath, fileProperty);
}
catch (const std::exception &e)
+1
View File
@@ -109,6 +109,7 @@ namespace pipedal
using NetworkChangedListener = std::function<void(void)>;
private:
PedalboardItem* GetPedalboardItemForFileProperty(const UiFileProperty& fileProperty);
void CancelAudioRetry();
clock::time_point lastRestartTime = clock::time_point::min();
+14
View File
@@ -1547,6 +1547,20 @@ static void createTargetLinks(const std::filesystem::path &sourceDirectory, cons
}
}
}
std::string PluginHost::MapResourcePath(const std::string&pluginUri, const std::string&filePath)
{
auto plugin = GetPluginInfo(pluginUri);
if (plugin) {
return filePath;
}
return filePath;
}
void PluginHost::CheckForResourceInitialization(const std::string &pluginUri, const std::filesystem::path &pluginUploadDirectory)
{
+3
View File
@@ -838,6 +838,9 @@ namespace pipedal
public:
virtual MapFeature &GetMapFeature() { return this->mapFeature; }
void CheckForResourceInitialization(const std::string& pluginUri,const std::filesystem::path& pluginUploadDirectory);
std::string MapResourcePath(const std::string&uri, const std::string&relativePath);
void ReloadPlugins();
// equivalent to LV2 MapPath AbstractPath features.
+8 -29
View File
@@ -46,32 +46,6 @@ const char *BANKS_FILENAME = "index.banks";
#define USER_SETTINGS_FILENAME "userSettings.json";
static bool isSubdirectory(const fs::path &path, const fs::path &basePath)
{
auto iPath = path.begin();
for (auto i = basePath.begin(); i != basePath.end(); ++i)
{
if (iPath == path.end())
{
return false;
}
if ((*i) != (*iPath))
{
return false;
}
++iPath;
}
while (iPath != path.end())
{
if (iPath->string() == "..")
{
return false;
}
++iPath;
}
return true;
}
static bool hasSyntheticModRoot(const UiFileProperty &fileProperty)
{
@@ -1755,7 +1729,7 @@ FileRequestResult Storage::GetModFileList2(const std::string &relativePath, cons
const ModFileTypes::ModDirectory *modDirectoryInfo = ModFileTypes::GetModDirectory(modDirectory);
if (modDirectoryInfo)
{
if (isSubdirectory(fsRelativePath, uploadsDirectory / modDirectoryInfo->pipedalPath))
if (IsSubdirectory(fsRelativePath, uploadsDirectory / modDirectoryInfo->pipedalPath))
{
rootModDirectory = modDirectoryInfo;
modDirectoryPath = uploadsDirectory / modDirectoryInfo->pipedalPath;
@@ -1766,7 +1740,7 @@ FileRequestResult Storage::GetModFileList2(const std::string &relativePath, cons
}
if (modDirectoryPath.empty() && fileProperty.useLegacyModDirectory())
{
if (isSubdirectory(fsRelativePath, uploadsDirectory / fileProperty.directory()))
if (IsSubdirectory(fsRelativePath, uploadsDirectory / fileProperty.directory()))
{
modDirectoryPath = uploadsDirectory / fileProperty.directory();
result.breadcrumbs_.push_back({modDirectoryPath.string(), fs::path(fileProperty.directory()).filename().string()});
@@ -1881,7 +1855,7 @@ FileRequestResult Storage::GetFileList2(const std::string &relativePath_, const
++iAbsolutePath;
}
}
if (!isSubdirectory(absolutePath, pluginRootDirectory))
if (!IsSubdirectory(absolutePath, pluginRootDirectory))
{
throw std::runtime_error(SS("Improper location. " << absolutePath));
}
@@ -2239,6 +2213,11 @@ FilePropertyDirectoryTree::ptr Storage::GetFilePropertydirectoryTree(const UiFil
}
}
bool Storage::IsInUploadsDirectory(const std::filesystem::path&path) const
{
return IsSubdirectory(path,this->GetPluginUploadDirectory());
}
const PluginPresetIndex &Storage::GetPluginPresetIndex()
{
return pluginPresetIndex;
+2
View File
@@ -154,6 +154,8 @@ public:
void MoveBank(int from, int to);
int64_t DeleteBank(int64_t bankId);
bool IsInUploadsDirectory(const std::filesystem::path&path) const;
FileRequestResult GetFileList2(const std::string&relativePath,const UiFileProperty&fileProperty);
FileRequestResult GetModFileList2(const std::string &relativePath,const UiFileProperty &fileProperty);