Skip to content

Commit

Permalink
Move interpolation type from Variants to SingleVariant (#1283)
Browse files Browse the repository at this point in the history
* move interpolation type from Variants to SingleVariant

* fix clang format

* Add the streaming for interpoation on SingleVariant

---------

Co-authored-by: Paul Walker <[email protected]>
  • Loading branch information
luismrguimaraes and baconpaul authored Sep 8, 2024
1 parent 15f8c82 commit 61fb9a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void VariantDisplay::rebuild()
break;
}

switch (variantView.interpolationType)
switch (variantView.variants[selectedVariation].interpolationType)
{
case dsp::InterpolationTypes::Sinc:
srcButton->setLabel("SINC");
Expand Down Expand Up @@ -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<cmsg::UpdateZoneVariantsInt16TValue>(
variantView, variantView.interpolationType, this);
rebuild();
});
p.addItem(
n, true, variantView.variants[selectedVariation].interpolationType == e, [this, e]() {
variantView.variants[selectedVariation].interpolationType = e;
connectors::updateSingleValue<cmsg::UpdateZoneVariantsInt16TValue>(
variantView, variantView.variants[selectedVariation].interpolationType, this);
rebuild();
});
};
add(dsp::InterpolationTypes::Sinc, "Sinc");
add(dsp::InterpolationTypes::Linear, "Linear");
Expand Down
2 changes: 1 addition & 1 deletion src/engine/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct Zone : MoveableOnly<Zone>, HasGroupZoneProcessors<Zone>, 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};
Expand All @@ -132,7 +133,6 @@ struct Zone : MoveableOnly<Zone>, HasGroupZoneProcessors<Zone>, SampleRateSuppor
{
std::array<SingleVariant, maxVariantsPerZone> variants;
VariantPlaybackMode variantPlaybackMode{FORWARD_RR};
dsp::InterpolationTypes interpolationType{dsp::InterpolationTypes::Sinc};
} variantData;

std::array<std::shared_ptr<sample::Sample>, maxVariantsPerZone> samplePointers;
Expand Down
3 changes: 3 additions & 0 deletions src/json/engine_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/voice/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 61fb9a2

Please sign in to comment.