would be cool to have a templatized AudioSampleBuffer<> to use doubles to take advantage of copy/ramping functionality of the class on the new datatype too. Also i think that there should be a way to specify byte alignment of the HeapBlock in AudioSampleBuffer so one can specify 16 or 32 bytes alignment and let the compiler automatic handle sse/avx optimizations on operations...
i thought also about having a pluggable LowLevelAudioSampleBufferContext class that will implement low level copy, assign, multiply and other operations on the buffer, for example in commercial programs you would want to have a IPP backend to speed up things (this will require 32byte alignment of buffers to take advantage of avx and avx2 on modern archs).
As mentioned elsewhere, I'm planning on extending it so that the buffer can use floats, doubles or ints internally, and can swap between these internal representations on demand. Doing it that way will mean that existing code won't need to be changed, and will often be able to take advantage of using doubles without needing to be updated.
(Using a template would mean that all existing code would get broken, and it'd make it much harder to write functions that can handle either floats or doubles, as all your functions would also need to be templated)
The buffers are already 8-byte (or maybe 16-byte?) aligned. AFAIK all vector operations work fine like this, so I'm not sure why anyone would ever want it to be 32-byte aligned?
Intel® AVX has relaxed some memory alignment requirements, so now Intel AVX by default allows unaligned access; however, this access may come at a performance slowdown, so the old rule of designing your data to be memory aligned is still good practice (16-byte aligned for 128-bit access and 32-byte aligned for 256-bit access). The main exceptions are the VEX-extended versions of the SSE instructions that explicitly required memory-aligned data: These instructions still require aligned data.
anyway to be sure buffers are aligned they should be allocated with _aligned_malloc, aligned_alloc, posix_memalign
- an internal memory cache (shared along the process, threadsafe) , to reuse once allocated memory ( or preserve memory for this reason ) to fast usage inside audio callbacks (without OS malloc callback) when working with stacked AudioSampleBuffers in audio-callbacks
I would prefer to pre-calculate window vectors and apply them in simple vector multiplications - and re-initialize them when the target buffer size is changed (e.g. FFT vector).
well this is are just basic helper functions, which can be applied on a single buffer, as addition to AudioSampleBuffer
You could used such methods to get this behavior ( fill Buffer with 1, apply window , reusing and apply vector multiplication), i think the functionaly you mention needs to be implemented in a derived/or another class