[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] Possible unnecessary calculation in LOOP_BODY_* in DelayUgens.cpp?



Hi all,

I've just noticed that in the LOOP_BODY_* macros in DelayUGens.cpp 2 variables (index and channel) are incremented when iterating over channels and writing stuff out?

Here's the excerpt from LOOP_BODY_4 where it occurs:

int32 index = 0; \
float fracphase = phase - (double)iphase; \
for (uint32 channel=0; channel<numOutputs; ++channel) { \
float a = table0[index]; \
float b = table1[index]; \
float c = table2[index]; \
float d = table3[index]; \
OUT(channel)[SAMPLE_INDEX] = cubicinterp(fracphase, a, b, c, d); \
index++; \ // <- !!!!! is index really neccesary? !!!!
}

In the Ugen I've been writing I've managed to get things working in a manner similar to this:

float fracphase = phase - (double)iphase; \
for (uint32 channel=0; channel<numOutputs; ++channel) { \
float a = table0[channel]; \
float b = table1[channel]; \
float c = table2[channel]; \
float d = table3[channel]; \
OUT(channel)[SAMPLE_INDEX] = cubicinterp(fracphase, a, b, c, d); \
}

Is this something to with getting the code working on odd architectures or something? I usually avoid C++ as much as possible so can only imagine this is something to do with shifting the table pointers along safely or some other similarly hideous thing.

Is there a reason for them being there or have they just been missed?

Cheers,
Tristan