Are AudioBuffers channels allways SIMD aligned?

My question is whether the AudioBuffer object allways creates channels with startadresses that are aligned with the machines SIMD vectorsize.
I checked here on my mac M1 and on iOS, and it allways seems to create channels that have adresses that are aligned to 16 bytes, which is also the vectorsize.

I use some custom code that casts an audiobuffer to SIMD float. I could ofcourse copy unaligned stuff to solid SIMD aligned dataspace, when it is not safe, but when this is a know feature, well, why not use it.
In the past I have used alignas(), to make sure data is aligned for sure casting, but ofcourse the AudioBuffer object has its own style.

1 Like

I think you have to differentiate between AudioBuffers that allocate their memory themselves and AudioBuffers that wrap external buffers. Especially the buffer instances that are passed to processBlock usually wrap pointer to memory buffers allocated by the host. I don’t think that the plugin formats specify any alignment requirements for such buffers, so all bets are off in that case.

For memory allocated by the AudioBuffer class itself, you can see how the alignment is chosen by looking at the sources:

To me this looks like no special over-alignment suitable for e.g. AVX, but the value is 16 on my Intel mac.

1 Like

yes, allso my thoughts exactly… I also noticed this aligment scheme, where no SIMD sizes are incorporated.
I’ll make solid aligned buffers for the spots where I use my custom SIMD stuff, I’d rather have a 0.05% CPU penalty than having everything crashing in X years, because SIMD changed but not the JUCE alignment…