S4 Tier 0: the bank plays — VST3 marshals MIDI to the S3 core, reads the live bank + resolves WAV the M4 way, mono downmix, lock-free load handoff, LICE sample-pick

This commit is contained in:
2026-07-26 16:43:04 -04:00
parent b0fc052113
commit 0cde457224
24 changed files with 1239 additions and 302 deletions
-62
View File
@@ -13,66 +13,4 @@ std::optional<std::string> decodeGetProjExtState(int apiReturn,
return buffer;
}
std::optional<std::string> extractJsonStringField(const std::string& json,
const std::string& key) {
// Find the member token: "key" followed (after optional whitespace) by ':' then a
// quoted string. Scan for each candidate occurrence of the quoted key so a value
// that happens to contain the key text can't produce a false match.
const std::string needle = "\"" + key + "\"";
size_t searchFrom = 0;
while (true) {
const size_t keyPos = json.find(needle, searchFrom);
if (keyPos == std::string::npos) return std::nullopt;
size_t i = keyPos + needle.size();
searchFrom = i; // next candidate starts after this key token
// Skip whitespace to the ':'.
while (i < json.size() &&
(json[i] == ' ' || json[i] == '\t' || json[i] == '\n' ||
json[i] == '\r')) {
++i;
}
if (i >= json.size() || json[i] != ':') continue; // not a member — keep looking
++i;
// Skip whitespace to the value.
while (i < json.size() &&
(json[i] == ' ' || json[i] == '\t' || json[i] == '\n' ||
json[i] == '\r')) {
++i;
}
if (i >= json.size() || json[i] != '"') return std::nullopt; // value not a string
++i;
// Read the string body, honoring the common JSON escapes.
std::string out;
while (i < json.size()) {
const char c = json[i];
if (c == '\\') {
if (i + 1 >= json.size()) return std::nullopt; // dangling escape
const char e = json[i + 1];
switch (e) {
case '"': out.push_back('"'); break;
case '\\': out.push_back('\\'); break;
case '/': out.push_back('/'); break;
case 'n': out.push_back('\n'); break;
case 't': out.push_back('\t'); break;
case 'r': out.push_back('\r'); break;
case 'b': out.push_back('\b'); break;
case 'f': out.push_back('\f'); break;
default: out.push_back(e); break; // pass through unknown escapes
}
i += 2;
continue;
}
if (c == '"') return out; // closing quote — done
out.push_back(c);
++i;
}
return std::nullopt; // unterminated string
}
}
} // namespace reasampler::vst