Skip to content

Commit

Permalink
plugins: don't call ZIN0 in LOOP. This fixes #1278.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Rohrhuber committed Dec 16, 2014
1 parent 9ff2f21 commit 8b1b55f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions server/plugins/NoiseUGens.cpp
Expand Up @@ -556,6 +556,8 @@ void TRand_next_k(TRand* unit, int inNumSamples)

void TRand_next_a(TRand* unit, int inNumSamples)
{
float lo = ZIN0(0);
float hi = ZIN0(1);
float *trig = ZIN(2);
float prev = unit->m_trig;
float *out = ZOUT(0);
Expand All @@ -565,8 +567,6 @@ void TRand_next_a(TRand* unit, int inNumSamples)
LOOP1(inNumSamples,
next = ZXP(trig);
if (next > 0.f && prev <= 0.f) {
float lo = ZIN0(0);
float hi = ZIN0(1);
float range = hi - lo;
RGen& rgen = *unit->mParent->mRGen;
ZXP(out) = outval = rgen.frand() * range + lo;
Expand Down Expand Up @@ -611,6 +611,8 @@ void TExpRand_next_k(TExpRand* unit, int inNumSamples)

void TExpRand_next_a(TExpRand* unit, int inNumSamples)
{
float lo = ZIN0(0);
float hi = ZIN0(1);
float *trig = ZIN(2);
float prev = unit->m_trig;
float *out = ZOUT(0);
Expand All @@ -620,8 +622,6 @@ void TExpRand_next_a(TExpRand* unit, int inNumSamples)
LOOP1(inNumSamples,
next = ZXP(trig);
if (next > 0.f && prev <= 0.f) {
float lo = ZIN0(0);
float hi = ZIN0(1);
float ratio = hi / lo;
RGen& rgen = *unit->mParent->mRGen;
ZXP(out) = outval = pow(ratio, rgen.frand()) * lo;
Expand Down Expand Up @@ -677,6 +677,8 @@ void TIRand_next_k(TIRand* unit, int inNumSamples)

void TIRand_next_a(TIRand* unit, int inNumSamples)
{
int lo = (int)ZIN0(0);
int hi = (int)ZIN0(1);
float *trig = ZIN(2);
float prev = unit->m_trig;
float *out = ZOUT(0);
Expand All @@ -686,8 +688,6 @@ void TIRand_next_a(TIRand* unit, int inNumSamples)
LOOP1(inNumSamples,
next = ZXP(trig);
if (next > 0.f && prev <= 0.f) {
int lo = (int)ZIN0(0);
int hi = (int)ZIN0(1);
int range = hi - lo + 1;
RGen& rgen = *unit->mParent->mRGen;
ZXP(out) = outval = (float)(rgen.irand(range) + lo);
Expand Down
7 changes: 4 additions & 3 deletions server/plugins/TriggerUGens.cpp
Expand Up @@ -764,14 +764,15 @@ void SendTrig_next(SendTrig *unit, int inNumSamples)
void SendTrig_next_aka(SendTrig *unit, int inNumSamples)
{
float *trig = ZIN(0);
float *value = ZIN(2);
int id = (int)ZIN0(1);
float *value = ZIN(2);
float prevtrig = unit->m_prevtrig;

LOOP1(inNumSamples,
float curtrig = ZXP(trig);
float curval = ZXP(value);
float curval = ZXP(value);
if (curtrig > 0.f && prevtrig <= 0.f) {
SendTrigger(&unit->mParent->mNode, (int)ZIN0(1), curval);
SendTrigger(&unit->mParent->mNode, id, curval);
}
prevtrig = curtrig;
);
Expand Down

0 comments on commit 8b1b55f

Please sign in to comment.