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

Microgate loop time is sample rate independent #55

Merged
merged 1 commit into from
Apr 7, 2024
Merged
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
11 changes: 7 additions & 4 deletions include/sst/voice-effects/distortion/Microgate.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V
{
static constexpr const char *effectName{"MicroGate"};

static constexpr int microgateBufferSize{4096};
static constexpr int microgateBufferSize{8192};
static constexpr int microgateBlockSize{microgateBufferSize * sizeof(float) * 2};

enum struct MicroGateParams
Expand Down Expand Up @@ -107,7 +107,6 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V
mech::copy_from_to<blockSize>(datainL, dataoutL);
mech::copy_from_to<blockSize>(datainR, dataoutR);

// TODO fixme
float threshold = this->dbToLinear(this->getFloatParam((int)MicroGateParams::threshold));
float reduction = this->dbToLinear(this->getFloatParam((int)MicroGateParams::reduction));
mReductionLerp.newValue(reduction);
Expand Down Expand Up @@ -137,7 +136,8 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V
if ((!(onesampledelay[0] * datainL[k] > 0)) && (datainL[k] > 0))
{
gate_zc_sync[0] = gate_state;
int looplimit = (int)(float)(4 + 3900 * loopParam * loopParam);
int looplimit =
(int)(float)(4 + 3900 * loopParam * loopParam * this->getSampleRate() / 48000);
if (bufpos[0] > looplimit)
{
is_recording[0] = false;
Expand All @@ -147,7 +147,8 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V
if ((!(onesampledelay[1] * datainR[k] > 0)) && (datainR[k] > 0))
{
gate_zc_sync[1] = gate_state;
int looplimit = (int)(float)(4 + 3900 * loopParam * loopParam);
int looplimit =
(int)(float)(4 + 3900 * loopParam * loopParam * this->getSampleRate() / 48000);
if (bufpos[1] > looplimit)
{
is_recording[1] = false;
Expand All @@ -168,7 +169,9 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V
dataoutL[k] = loopbuffer[0][bufpos[0] & (microgateBufferSize - 1)];
bufpos[0]++;
if (bufpos[0] >= buflength[0])
{
bufpos[0] = 0;
}
}
}
else
Expand Down
Loading