Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move interpolation type from Variants to SingleVariant #1283

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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};
mkruselj marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading