cb6b63cc88
REAPER may not expose the parent project pointer during plugin creation/setState, so the instrument would silently resolve no sample roots. Only that null-parent case now falls back to EnumProjects(-1); a resolved-but-unlisted or unsaved project still resolves nothing.
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
// sample_roots.cpp — see sample_roots.h.
|
|
|
|
#include "core/instrument/map/sample_roots.h"
|
|
|
|
#include "core/capture/capture_paths.h" // projectDirOfRpp / resolveBankFile (persist's convention)
|
|
|
|
namespace reasampler::instrument::map {
|
|
|
|
std::string ownProjectDir(const void* own, const std::vector<ProjectTab>& open,
|
|
const void* activeFallback) {
|
|
const void* target = own ? own : activeFallback;
|
|
if (!target) return {};
|
|
for (const ProjectTab& tab : open) {
|
|
if (tab.project == target) return capture::projectDirOfRpp(tab.rppPath);
|
|
}
|
|
return {};
|
|
}
|
|
|
|
std::vector<std::string> sampleRootCandidates(const std::string& projectDir) {
|
|
if (projectDir.empty()) return {};
|
|
return {projectDir};
|
|
}
|
|
|
|
std::vector<std::uint8_t> readFromFirstRoot(const std::vector<std::string>& roots,
|
|
const std::string& relativePath,
|
|
const FileReader& read) {
|
|
for (const std::string& root : roots) {
|
|
const std::string abs = capture::resolveBankFile(root, relativePath);
|
|
if (abs.empty()) continue;
|
|
std::vector<std::uint8_t> bytes = read(abs);
|
|
if (!bytes.empty()) return bytes;
|
|
}
|
|
return {};
|
|
}
|
|
|
|
} // namespace reasampler::instrument::map
|