Why doesn't dsp::AudioBlock provide safe single sample access?


#1

Hi,

I’m trying to use the new dsp::AudioBlock, but I’m missing the getSample/setSample methods (which are available in the “old” AudioBuffer). Any good reason why they aren’t available? From my perspective it would be great to add them so I can access memory safely through these methods, rather than having to get the raw pointers and then use them.

Thanks,
Dan


#2

No particular reason… I guess we could add them!

I think it probably just got overlooked since most people will tend to grab a pointer and iterate over it to avoid the overhead of each get/set call.


#3

Great. I believe the extra pointer+offset calculations and functions calls would usually be negligible if not zero due to compiler optimization, and I’d gladly pay that to have jasserts catching bugs in debug builds.


#4

Yes, fair point, the compiler could …probably… figure out that it can remove them if the calls get inlined!