Sticky delay line buffer indices
Captain's Log: Stardate 77516.5
Delay lines are now fully working, with all the features needed to make use of them in various use-cases. Both audio input exciters and microphones can have their external inputs/outputs disabled, so they can be used for purely internal signal chains. Modulation is implemented for the delay time, which works great and can produce some extremely cool sounds. I produced a YouTube walk-through video that I'll release next week (since video releases on Friday don't go well).
There is one remaining under-the-hood thing I need to do, though, which is to make the delay buffer index for each sensor "sticky" even in weird situations like the sensor being deleted and then having that delete be undone.
The problem is that the delay buffer is quite large. Right now I am pre-allocating 1 second of delay buffer for every sensor, which at 48kHz is 4 bytes * 2 channels * 48k samples, or about 1/3 of a megabyte. Times 50 sensors. Copying that data around (even just the 1/3 megabyte) is not something I want to do in the audio thread.
So, each sensor is allocated an index into that big sample buffer, and if deleting and recreating a sensor did not somehow maintain a stable index, it might switch to a different part of the sample buffer, and delay lines reading from the sensor would output old data from some other sensor! This also brings up another related problem, which is that when a sensor is created it could be allocated a buffer that already contains old data, and it shouldn't play that data back.
So in addition to stable buffer indexes, I also will probably need to set a creation timestamp on each exciter (in sample time), and elide any delay playback from before that. A simpler solution would be to clear the sample buffer for the new exciter, but that's much too slow.