void Impulse_next_aa(Impulse *unit, int inNumSamples)
{
float *out = ZOUT(0);
float *freq = ZIN(0);
float *phaseOffset = ZIN(1);
float freqmul = unit->mFreqMul;
double phase = unit->mPhase;
double rate_acum = unit->mPhase;
// double phaseSlope = CALCSLOPE(phaseOffset, prev_phaseOffset);
phase += unit->mPhaseOffset;
LOOP(inNumSamples,
float z;
if (phase >= 1.f) {
rate_acum -= 1.f;
z = 1.f;
} else if (phase < 0.f) {
rate_acum += 1.f;
z = 1.f;
}
else {
z = 0.f;
}
rate_acum += (ZXP(freq) * freqmul);
phase = rate_acum + ZXP(phaseOffset);
ZXP(out) = z;
);
unit->mPhase = rate_acum;
unit->mPhaseOffset = phase - rate_acum;
}