From 61fb9a2d5c256ec16ae884cb55b44e82cfc14b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20M=2E=20R=2E=20Guimar=C3=A3es?= <100025288+luismrguimaraes@users.noreply.github.com> Date: Sun, 8 Sep 2024 13:36:40 +0100 Subject: [PATCH] Move interpolation type from Variants to SingleVariant (#1283) * move interpolation type from Variants to SingleVariant * fix clang format * Add the streaming for interpoation on SingleVariant --------- Co-authored-by: Paul Walker --- .../components/mapping-pane/VariantDisplay.cpp | 15 ++++++++------- src/engine/zone.h | 2 +- src/json/engine_traits.h | 3 +++ src/voice/voice.cpp | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp b/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp index f840d3c9..7371aa2a 100644 --- a/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp +++ b/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp @@ -502,7 +502,7 @@ void VariantDisplay::rebuild() break; } - switch (variantView.interpolationType) + switch (variantView.variants[selectedVariation].interpolationType) { case dsp::InterpolationTypes::Sinc: srcButton->setLabel("SINC"); @@ -727,12 +727,13 @@ void VariantDisplay::showSRCMenu() p.addSeparator(); auto add = [&p, this](auto e, auto n) { - p.addItem(n, true, variantView.interpolationType == e, [this, e]() { - variantView.interpolationType = e; - connectors::updateSingleValue( - variantView, variantView.interpolationType, this); - rebuild(); - }); + p.addItem( + n, true, variantView.variants[selectedVariation].interpolationType == e, [this, e]() { + variantView.variants[selectedVariation].interpolationType = e; + connectors::updateSingleValue( + variantView, variantView.variants[selectedVariation].interpolationType, this); + rebuild(); + }); }; add(dsp::InterpolationTypes::Sinc, "Sinc"); add(dsp::InterpolationTypes::Linear, "Linear"); diff --git a/src/engine/zone.h b/src/engine/zone.h index 63ff6676..8049acb5 100644 --- a/src/engine/zone.h +++ b/src/engine/zone.h @@ -109,6 +109,7 @@ struct Zone : MoveableOnly, HasGroupZoneProcessors, SampleRateSuppor bool active{false}; SampleID sampleID; int64_t startSample{-1}, endSample{-1}, startLoop{-1}, endLoop{-1}; + dsp::InterpolationTypes interpolationType{dsp::InterpolationTypes::Sinc}; // VariantMode variantMode{RR}; PlayMode playMode{NORMAL}; @@ -132,7 +133,6 @@ struct Zone : MoveableOnly, HasGroupZoneProcessors, SampleRateSuppor { std::array variants; VariantPlaybackMode variantPlaybackMode{FORWARD_RR}; - dsp::InterpolationTypes interpolationType{dsp::InterpolationTypes::Sinc}; } variantData; std::array, maxVariantsPerZone> samplePointers; diff --git a/src/json/engine_traits.h b/src/json/engine_traits.h index b51ee33c..95d2b931 100644 --- a/src/json/engine_traits.h +++ b/src/json/engine_traits.h @@ -319,6 +319,7 @@ SC_STREAMDEF(scxt::engine::Zone::SingleVariant, SC_FROM({ {"loopMode", s.loopMode}, {"loopDirection", s.loopDirection}, {"loopCountWhenCounted", s.loopCountWhenCounted}, + {"interpolationType", s.interpolationType}, {"loopFade", s.loopFade}}; } else @@ -344,6 +345,8 @@ SC_STREAMDEF(scxt::engine::Zone::SingleVariant, SC_FROM({ findOrSet(v, "loopDirection", engine::Zone::LoopDirection::FORWARD_ONLY, s.loopDirection); findOrSet(v, "loopFade", 0, s.loopFade); + findOrSet(v, "interpolationType", dsp::InterpolationTypes::Sinc, + s.interpolationType); findOrSet(v, "loopCountWhenCounted", 0, s.loopCountWhenCounted); } else diff --git a/src/voice/voice.cpp b/src/voice/voice.cpp index 073e6f3c..a3ab9834 100644 --- a/src/voice/voice.cpp +++ b/src/voice/voice.cpp @@ -537,7 +537,7 @@ void Voice::initializeGenerator() return; } - // but the default of course is to use the sapmle index + // but the default of course is to use the sample index auto &s = zone->samplePointers[sampleIndex]; auto &variantData = zone->variantData.variants[sampleIndex]; assert(s); @@ -598,7 +598,7 @@ void Voice::initializeGenerator() variantData.loopDirection == engine::Zone::FORWARD_ONLY, variantData.loopMode == engine::Zone::LOOP_WHILE_GATED); - GD.interpolationType = zone->variantData.interpolationType; + GD.interpolationType = variantData.interpolationType; } float Voice::calculateVoicePitch()