Hi Pablo,
On 15/11/2024 3:18 pm, Pablo Frank wrote:
Thanks, I did one more change in soundout and it works perfectly:
for(int i=0; i < bufs; i++){
oscc(&buffer[i], amp, freq, wave, &ndx, WAVE_SIZE, SR);
outBuf[i] = feedforward(buffer ,i ,a0 ,a1 ,1);
soundout(psf,&outBuf[i], 1); //<—---------------HERE
}
Now there is no reason to pass the buffer to oscc, so I would do the
following:
- change the oscc function to return the output value rather than
passing a pointer for the return value
- move the buffer update inside `feedforward`, something like:
float feedforward(float input, float *buffer, int index, double a0,
double a1, int delay){
buffer[index] = input;
...
Then your main loop is cleaner:
for(int i=0; i < bufs; i++){
float a = oscc(amp, freq, wave, &ndx, WAVE_SIZE, SR);
float b = feedforward(a, buffer, i, a0, a1, 1);
soundout(psf, &b, 1);
}
Furthermore the data associated with each unit generator function is not
unnecessarily intertwined.
Now you can follow Stefano's earlier suggestion and update the
feedforward function to use a circular buffer. Then your main code no
longer depends on having a large buffer, and the filter code only needs
to be sized according to the maximum delay rather than the length of
your output.
Best wishes,
Ross.