Skip to content

Commit

Permalink
add proc interpolation (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismrguimaraes authored Sep 12, 2024
1 parent a74be29 commit 35ead74
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 13 deletions.
25 changes: 20 additions & 5 deletions include/sst/voice-effects/utilities/GainMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,35 @@ template <typename VFXConfig> struct GainMatrix : core::VoiceEffectTemplateBase<
void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
{

llLerp.set_target(this->getFloatParam(fpLeftToLeft));
float ll alignas(16)[VFXConfig::blockSize];
llLerp.store_block(ll);

rlLerp.set_target(this->getFloatParam(fpRightToLeft));
float rl alignas(16)[VFXConfig::blockSize];
rlLerp.store_block(rl);

rrLerp.set_target(this->getFloatParam(fpRightToRight));
float rr alignas(16)[VFXConfig::blockSize];
rrLerp.store_block(rr);

lrLerp.set_target(this->getFloatParam(fpLeftToRight));
float lr alignas(16)[VFXConfig::blockSize];
lrLerp.store_block(lr);

for (int i = 0; i < VFXConfig::blockSize; i++)
{
auto sL = datainL[i];
auto sR = datainR[i];

dataoutL[i] =
sL * this->getFloatParam(fpLeftToLeft) + sR * this->getFloatParam(fpRightToLeft);
dataoutR[i] =
sR * this->getFloatParam(fpRightToRight) + sL * this->getFloatParam(fpLeftToRight);
dataoutL[i] = sL * ll[i] + sR * rl[i];
dataoutR[i] = sR * rr[i] + sL * lr[i];
}
}

protected:
sst::basic_blocks::dsp::lipol_sse<VFXConfig::blockSize, true> volLerp, leftLerp, rightLerp;
sst::basic_blocks::dsp::lipol_sse<VFXConfig::blockSize, true> llLerp, rlLerp, rrLerp, lrLerp;
};
} // namespace sst::voice_effects::utilities
#endif // SCXT_GAINMATRIX_H
37 changes: 29 additions & 8 deletions include/sst/voice-effects/utilities/StereoTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,34 @@ template <typename VFXConfig> struct StereoTool : core::VoiceEffectTemplateBase<
void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
{
auto rotRadians = this->getFloatParam(fpRotation) * 0.017453292; // degrees * PI/180
auto width = this->getFloatParam(fpWidth) / 2.f;
auto side = std::min(this->getFloatParam(fpMidSide) + 1, 1.f);
auto center = 1 - this->getFloatParam(fpMidSide);
auto left = -std::min(this->getFloatParam(fpLeftRight), 0.f);
auto left1 = -std::max(this->getFloatParam(fpLeftRight) - 1, -1.f);
auto right = std::max(this->getFloatParam(fpLeftRight), 0.f);
auto right1 = std::min(1 + this->getFloatParam(fpLeftRight), 1.f);

rotLerp.set_target(this->getFloatParam(fpRotation));
float rot alignas(16)[VFXConfig::blockSize];
rotLerp.store_block(rot);

widthLerp.set_target(this->getFloatParam(fpWidth));
float w alignas(16)[VFXConfig::blockSize];
widthLerp.store_block(w);

msLerp.set_target(this->getFloatParam(fpMidSide));
float ms alignas(16)[VFXConfig::blockSize];
msLerp.store_block(ms);

lrLerp.set_target(this->getFloatParam(fpLeftRight));
float lr alignas(16)[VFXConfig::blockSize];
lrLerp.store_block(lr);

for (int i = 0; i < VFXConfig::blockSize; i++)
{
auto rotRadians = rot[i] * 0.017453292; // degrees * PI/180
auto width = w[i] / 2.f;
auto side = std::min(ms[i] + 1, 1.f);
auto center = 1 - ms[i];
auto left = -std::min(lr[i], 0.f);
auto left1 = -std::max(lr[i] - 1, -1.f);
auto right = std::max(lr[i], 0.f);
auto right1 = std::min(1 + lr[i], 1.f);

auto sL = datainL[i];
auto sR = datainR[i];

Expand Down Expand Up @@ -131,6 +148,10 @@ template <typename VFXConfig> struct StereoTool : core::VoiceEffectTemplateBase<
dataoutR[i] = sR;
}
}

protected:
sst::basic_blocks::dsp::lipol_sse<VFXConfig::blockSize, true> rotLerp, widthLerp, msLerp,
lrLerp;
};
} // namespace sst::voice_effects::utilities
#endif // SCXT_STEREOTOOL_H

0 comments on commit 35ead74

Please sign in to comment.