gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit be5dbe374985249ecdc8c4db5bbc1041db1fae5b
parent 4ec08215d79e91cf01a3250a8e9a449af7a56564
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue, 15 Feb 2022 23:42:37 +0100

allow to search for a ROM based on min- and max-size constraints

Diffstat:
Msource/synthLib/os.cpp | 18++++++++++++++----
Msource/synthLib/os.h | 5+++--
2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/source/synthLib/os.cpp b/source/synthLib/os.cpp @@ -111,7 +111,7 @@ namespace synthLib return std::string(); } - std::string findROM(const size_t _expectedSize) + std::string findROM(size_t _minSize, size_t _maxSize) { std::string path = getModulePath(); @@ -137,7 +137,7 @@ namespace synthLib if (ext != ".bin") continue; - if (_expectedSize) + if (_minSize || _maxSize) { FILE *hFile = fopen(file.c_str(), "rb"); if (!hFile) @@ -146,8 +146,11 @@ namespace synthLib fseek(hFile, 0, SEEK_END); const auto size = ftell(hFile); fclose(hFile); - if (size != _expectedSize) + + if (_minSize && size < _minSize) continue; + if (_maxSize && size > _maxSize) + continue; LOG("Found ROM at path " << file); @@ -173,8 +176,10 @@ namespace synthLib if (!file.has_extension()) continue; - if (_expectedSize && entry.file_size() != _expectedSize) + if (_minSize && entry.file_size() < _minSize) continue; + if (_maxSize && entry.file_size() > _maxSize) + continue; std::string ext = lowercase(file.extension().string()); @@ -194,6 +199,11 @@ namespace synthLib return std::string(); } + std::string findROM(const size_t _expectedSize) + { + return findROM(_expectedSize, _expectedSize); + } + void setFlushDenormalsToZero() { #if defined(_MSC_VER) diff --git a/source/synthLib/os.h b/source/synthLib/os.h @@ -4,6 +4,7 @@ namespace synthLib { std::string getModulePath(); - std::string findROM(size_t _expectedSize = 524288); - void setFlushDenormalsToZero(); + std::string findROM(size_t _minSize, size_t _maxSize); + std::string findROM(size_t _expectedSize = 524288); + void setFlushDenormalsToZero(); } // namespace synthLib