Skip to content

Commit

Permalink
Remove retriggering
Browse files Browse the repository at this point in the history
  • Loading branch information
nidefawl committed Jun 5, 2016
1 parent 2efab6d commit 47524e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
35 changes: 4 additions & 31 deletions plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,10 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain

trk->OscPhase = fmod(trk->OscPhase, 1.0);
float Ratio = trk->ThisEndFrq / trk->ThisStartFrq;
if (trk->AntiClick<-64000) trk->AntiClick = -64000;
if (trk->AntiClick >= 64000) trk->AntiClick = 64000;
int i = 0;
double xSin = trk->xSin, xCos = trk->xCos;
double dxSin = trk->dxSin, dxCos = trk->dxCos;
float LVal = 0;
float AClick = trk->AntiClick;
float Amp = trk->Amp;
float DecAmp = trk->DecAmp;
float BAmp = trk->BAmp;
Expand All @@ -583,15 +580,6 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain
int proc = 0;
while (i<c)
{

if (trk->SamplesToGo == 1)
{
trk->trigger();
AClick = trk->AntiClick;
Age = trk->Age;
Amp = trk->Amp;
dprintf("retrigger.\n");
}
if (trk->LeftOver <= 0)
{
trk->LeftOver = 32;
Expand All @@ -618,7 +606,7 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain
{
trk->Amp = 0;
trk->DecAmp = 0;
if (fabs(AClick)<0.00012f && !trk->SamplesToGo)
if (!trk->SamplesToGo)
return amphigh;
}

Expand Down Expand Up @@ -651,7 +639,7 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain
{
for (int j = i; j<max; j++)
{
pout[j] += float(LVal = float(AClick + Amp*Vol*xSin));
pout[j] += float(LVal = float(Amp*Vol*xSin));
if (xSin>0)
{
float D = (float)(Amp*Vol*BAmp*xSin*xCos);
Expand All @@ -663,20 +651,17 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain
xSin = xSin2; xCos = xCos2;
Amp -= DecAmp;
BAmp *= MulBAmp;
AClick *= 0.98f;
}
}
else
for (int j = i; j<max; j++)
{
pout[j] += float(LVal = float(AClick + Amp*Vol*xSin));
pout[j] += float(LVal = float(Amp*Vol*xSin));
double xSin2 = double(xSin*dxCos + xCos*dxSin);
double xCos2 = double(xCos*dxCos - xSin*dxSin);
xSin = xSin2; xCos = xCos2;
Amp -= DecAmp;
AClick *= 0.98f;
}
if (fabs(AClick)<0.0001f) AClick = 0.0001f;
if (OldAmp>0.1f && CAmp>0.001f)
{
int max2 = i + min(max - i, 1024 - Age);
Expand Down Expand Up @@ -704,8 +689,6 @@ bool FSM_VST_Plugin::processVoice(FSM_Voice *trk, float *pout, int c, float gain
}

trk->xSin = xSin, trk->xCos = xCos;
trk->LastValue = LVal;
trk->AntiClick = AClick;
trk->Amp = Amp;
trk->BAmp = BAmp;
trk->CAmp = CAmp;
Expand Down Expand Up @@ -772,13 +755,10 @@ FSM_Voice::FSM_Voice(VstInt32 note, VstInt32 velocity, VstInt32 delta) {
Amp = 0;
LeftOver = 32000;
EnvPhase = 6553600;
Retrig = 0;
SamplesToGo = 0;
EnvPhase = 0;
OscPhase = 0;
CurVolume = 32000;
LastValue = 0;
AntiClick = 0;
LeftOver = 0;
Age = 0;
Amp = 0;
Expand All @@ -796,14 +776,7 @@ FSM_Voice::FSM_Voice(VstInt32 note, VstInt32 velocity, VstInt32 delta) {

void FSM_Voice::trigger()
{
if (this->Retrig && this->RetrigCount>0)
{
this->SamplesToGo = this->Retrig;
this->RetrigCount--;
}
else
this->SamplesToGo = 0;
this->AntiClick = this->LastValue;
this->SamplesToGo = 0;
this->EnvPhase = 0;
this->OscPhase = this->ClickAmt;
this->LeftOver = 0;
Expand Down
4 changes: 0 additions & 4 deletions plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ class VoiceParameters
float ThisCDecay;
float CurVolume;
float ThisCurVolume;
float LastValue;
float AntiClick;
float ClickAmt;
float PunchAmt;
float BuzzAmt;
Expand All @@ -119,8 +117,6 @@ class VoiceParameters
float MulCAmp;
float Frequency;
int SamplesToGo;
int Retrig;
int RetrigCount;

double xSin, xCos, dxSin, dxCos;

Expand Down

0 comments on commit 47524e4

Please sign in to comment.