From 1ab92c4651b499b395a0a06e86f26860790630c9 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 15 Aug 2024 21:59:33 -0400 Subject: [PATCH] Upgrade taojson and start streaming optimization 1. Upgrade libs/taocppjson to latest 2. Start some streaming optimizations by making bus effects a bit smarter at none and macro way smarter, cutting a blank engine json stream down by about 2x. Addresses #1069 but still more to do. --- libs/taocpp_json | 2 +- src/engine/macros.h | 16 ++++--- src/engine/part.h | 2 + src/json/engine_traits.h | 95 ++++++++++++++++++++-------------------- src/json/scxt_traits.h | 24 ++++++++++ 5 files changed, 84 insertions(+), 55 deletions(-) diff --git a/libs/taocpp_json b/libs/taocpp_json index e710d017..b326963f 160000 --- a/libs/taocpp_json +++ b/libs/taocpp_json @@ -1 +1 @@ -Subproject commit e710d0173c4717c5a49e4b22511c394aa613d2b6 +Subproject commit b326963f28ede0747869ab53589fd86ef8321bb4 diff --git a/src/engine/macros.h b/src/engine/macros.h index c9e15840..2de6bc22 100644 --- a/src/engine/macros.h +++ b/src/engine/macros.h @@ -43,6 +43,8 @@ struct Macro { float value{0.f}; // -1 .. 1 + int16_t part{-1}, index{-1}; + bool isBipolar{false}; // The value is expected in range -1..1 bool isStepped{false}; // The value has discrete stepped value size_t stepCount{1}; // how many steps between min and max. @@ -100,17 +102,17 @@ struct Macro } static std::string defaultNameFor(int index) { return "Macro " + std::to_string(index + 1); } - std::string pluginParameterNameFor(int part, int index) const + std::string pluginParameterNameFor(int p, int i) const { - auto dn = defaultNameFor(index); + auto dn = defaultNameFor(i); if (name == dn) { - return std::string("P" + std::to_string(part + 1) + " " + name); + return std::string("P" + std::to_string(p + 1) + " " + name); } else { - return std::string("P" + std::to_string(part + 1) + " M" + std::to_string(index + 1) + - " - " + name); + return std::string("P" + std::to_string(p + 1) + " M" + std::to_string(i + 1) + " - " + + name); } } @@ -129,9 +131,9 @@ struct Macro } static int macroIDToPart(uint32_t id) { return (id - firstMacroParam) / macroParamPartStride; } static int macroIDToIndex(uint32_t id) { return (id - firstMacroParam) % macroParamPartStride; } - static uint32_t partIndexToMacroID(uint32_t part, uint32_t index) + static uint32_t partIndexToMacroID(uint32_t pt, uint32_t id) { - return firstMacroParam + part * macroParamPartStride + index; + return firstMacroParam + pt * macroParamPartStride + id; } }; } // namespace scxt::engine diff --git a/src/engine/part.h b/src/engine/part.h index 13f7f1a1..a90cf1bb 100644 --- a/src/engine/part.h +++ b/src/engine/part.h @@ -53,6 +53,8 @@ struct Part : MoveableOnly, SampleRateSupport int idx{0}; for (auto &m : macros) { + m.index = idx; + m.part = partNumber; m.name = Macro::defaultNameFor(idx); idx++; } diff --git a/src/json/engine_traits.h b/src/json/engine_traits.h index 3e3b05ef..3dfde3f2 100644 --- a/src/json/engine_traits.h +++ b/src/json/engine_traits.h @@ -123,17 +123,25 @@ SC_STREAMDEF(scxt::engine::Patch, SC_FROM({ })) SC_STREAMDEF(scxt::engine::Macro, SC_FROM({ - v = { - {"v", t.value}, {"bp", t.isBipolar}, {"st", t.isStepped}, - {"sc", t.stepCount}, {"nm", t.name}, - }; + v = {{"p", t.part}, {"i", t.index}, {"v", t.value}}; + + if (t.isBipolar) + SC_INSERT(v, "bp", t.isBipolar); + if (t.isStepped) + SC_INSERT(v, "st", t.isStepped); + if (t.stepCount != 1) + SC_INSERT(v, "sc", t.stepCount); + if (t.name != scxt::engine::Macro::defaultNameFor(t.index)) + SC_INSERT(v, "nm", t.name); }), SC_TO({ findIf(v, "v", result.value); - findIf(v, "bp", result.isBipolar); - findIf(v, "st", result.isStepped); - findIf(v, "sc", result.stepCount); - findIf(v, "nm", result.name); + findIf(v, "i", result.index); + findIf(v, "p", result.part); + findOrSet(v, "bp", false, result.isBipolar); + findOrSet(v, "st", false, result.isStepped); + findOrSet(v, "sc", 1, result.stepCount); + findOrSet(v, "nm", scxt::engine::Macro::defaultNameFor(result.index), result.name); })); SC_STREAMDEF( @@ -509,45 +517,38 @@ template <> struct scxt_traits } }; -template <> struct scxt_traits -{ - template