int a_mathops::momod_echo::run(int din)
{ // First, read a value out of the delay buffer at a point.
// in the past proportional to setting 'pram1'.
int delay = w->pram1 * ECHO_TRACE_LEN/100;
int p = ptr - delay - 1;
while (p < 0) p+= ECHO_TRACE_LEN;
// Multiply the old value by 'pram1' to adjust the amount of echo.
int echo = delaybuffer[p] * w->pram0 / 100;
// Combine current sample and the echo.
int r = din + echo;
// Write the result into the buffer, so echos re-circulate.
delaybuffer[ptr] = r;
ptr += 1;
if (ptr >= ECHO_TRACE_LEN) ptr = 0;
return r;
}
|
|