commit 04a4e3cd3f39868c2f79d922f091a80b8289a998
parent 7834d9f3cf6fa4d43ff2cd372e460c1201f2de9c
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 24 Oct 2024 19:12:47 +0200
support to load ROMs from user documents folder
Diffstat:
4 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/doc/changelog.txt b/doc/changelog.txt
@@ -21,6 +21,15 @@ Framework:
Existing skins in the old location are still supported to ensure backwards
compatibility
+- [Imp] ROMs are now also searched for in the following directories
+
+ c:\Users\<username>\Documents\<synthname>\roms (Win)
+ ~/Documents/<synthname>/roms (Mac)
+ [XDG_DATA_HOME or ~/.local/share]/<synthname>/roms (Linux)
+
+ For backwards compatibility, it is also possible to copy ROMs next to the
+ plugins as it was before
+
NodalRed2x:
- [Imp] Added indicator around knobs to show the current VMMap parameter value
diff --git a/source/jucePluginLib/processor.cpp b/source/jucePluginLib/processor.cpp
@@ -12,6 +12,7 @@
#include "dsp56kEmu/fastmath.h"
#include "dsp56kEmu/logging.h"
+#include "synthLib/romLoader.h"
namespace synthLib
{
@@ -25,6 +26,9 @@ namespace pluginLib
Processor::Processor(const BusesProperties& _busesProperties, Properties _properties) : juce::AudioProcessor(_busesProperties), m_properties(std::move(_properties)), m_midiPorts(*this)
{
+ synthLib::RomLoader::addSearchPath(synthLib::getModulePath(true));
+ synthLib::RomLoader::addSearchPath(synthLib::getModulePath(false));
+ synthLib::RomLoader::addSearchPath(Tools::getPublicDataFolder(getProperties().name) + "roms/");
}
Processor::~Processor()
diff --git a/source/synthLib/romLoader.cpp b/source/synthLib/romLoader.cpp
@@ -4,25 +4,25 @@
namespace synthLib
{
+ namespace
+ {
+ std::set<std::string> g_searchPaths;
+ }
std::vector<std::string> RomLoader::findFiles(const std::string& _extension, const size_t _minSize, const size_t _maxSize)
{
std::vector<std::string> results;
- const auto path = getModulePath();
- synthLib::findFiles(results, path, _extension, _minSize, _maxSize);
-
- const auto path2 = getModulePath(false);
- if(path2 != path)
- synthLib::findFiles(results, path2, _extension, _minSize, _maxSize);
-
- if(results.empty())
+ if(g_searchPaths.empty())
{
- const auto path3 = getCurrentDirectory();
- if(path3 != path2 && path3 != path)
- synthLib::findFiles(results, path, _extension, _minSize, _maxSize);
+ g_searchPaths.insert(getModulePath(true));
+ g_searchPaths.insert(getModulePath(false));
+ g_searchPaths.insert(getCurrentDirectory());
}
+ for (const auto& path : g_searchPaths)
+ synthLib::findFiles(results, path, _extension, _minSize, _maxSize);
+
return results;
}
@@ -35,4 +35,9 @@ namespace synthLib
synthLib::findFiles(results, _path, _extension, _minSize, _maxSize);
return results;
}
+
+ void RomLoader::addSearchPath(const std::string& _path)
+ {
+ g_searchPaths.insert(validatePath(_path));
+ }
}
diff --git a/source/synthLib/romLoader.h b/source/synthLib/romLoader.h
@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <cstddef>
+#include <set>
namespace synthLib
{
@@ -11,5 +12,7 @@ namespace synthLib
public:
static std::vector<std::string> findFiles(const std::string& _extension, size_t _minSize, size_t _maxSize);
static std::vector<std::string> findFiles(const std::string& _path, const std::string& _extension, size_t _minSize, size_t _maxSize);
+
+ static void addSearchPath(const std::string& _path);
};
}