Is it possible to write the audio buffers with an offset(delay) to generate a flat echo effect ?
The following piece of code outputs my audio buffers :
for(s=0; s<inNumberFrames; s++) {
ioBuffer[s] = audioBuffer[audioBufferReadPos];
}
Is it possible for me to do something like this within the for loop :
tempBuffer[s] = audioBuffer[audioBufferReadPos];
--- Then somehow offset tempBuffer[] as bufferWithOffset[] ---
ioBuffer[s] = audioBuffer[audioBufferReadPos] + bufferWithOffset[];
Any guidance in this regard will be highly appreciated.
Thanks.
Finally got it to work, thanks to Hollance on RW Forums for explaining all of this to me.
[ http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=2864 ]
I still have a lot of crashing issues, caused most probably by memory leaks. But the logic works.
Initialized a temporary buffer with 22050 zero samples :
Initialized a long counter with zero :
Then within the for loop fed the temporary buffer mixed with the current sample :
Added the current sample to the tempBuffer :
Reset the counter to zero if the limit of the tempBuffer is reached :
Assuming that the sampling rate is 44100 Hz, this will create a delay of 0.5 seconds.
UPDATE :
Changed
To
And that fixed the crashing.