Superpowered integration?


#1

Good day, so I am back again with a question to which the answer is likely obvious :slight_smile: . So I am in the process of integrating the Superpowered SDK into my JUCE application for some of its modules (currently the bandpassfilterbank), and I am running into memory issues (the code compiles but then crashes on opening due to some issues with matching data types (movss is the operation where the thread issue occurs). This is within the readpointer loop within the getNextAudioBlock method:

float *buff = const_cast<float*>(inputChannel);
superFB->process(buff, &this->bands[0][0], peak, sum, 
  sizeof(bufferToFill.buffer));      

The process method requires a 32-bit stereo input that is of type float *, but the read pointer from the buffer is of type const float, so I have to do some work arounds to get the parts to fit, so to speak. I may even be trying to do this in the wrong block or with the wrong variables? I am still getting accustomed to working with the lower-level aspects of programming, so thanks for taking the time to help me figure out what I am missing here.


#2

I am not completely sure what you are doing in the code, but one problem is that the Juce AudioBuffers are split multichannel buffers. If a 3rd party library requires interleaved multichannel buffers, there’s really no way around having to use an intermediary buffer that the Juce provided audio is converted into, then processed with the 3rd party code and finally converted back to be compatible with the Juce AudioBuffer.

With split buffers the audio is arranged like this in memory :

Buffer 1 : LLLL
Buffer 2 : RRRR

And with interleaved buffers :

Buffer : LRLRLRLR

#3

yep @Xenakios superpowered interfaces are all interleaved (apart from the outer audio callback which is float** as usual) - I guess they’re like that for better internal optimization/SIMD etc
@ToccataNos - superpowered has helpers to interleave/deinterleave and also juce might (never looked into that in juce)
furthermore superpoweredinterleave/superpowereddeinterleave methods are also good for wrapping your head around float* vs. float** and vice versa :wink:


#4

Hi thank-you both for your helpful pointers (no pun intended :wink:). I did notice the interleave modules in the Superpowered library, so I will likely spend tomorrow trying to get my head wrapped around that. Right now I am just trying to instantiate a SuperpoweredBandpassFilterbank object in the MainComponent, but i may transition into building a class that inherits from all of these SP classes and just invoke that, since it appears that its going to require some more intense work arounds to get the SP library to play well with the JUCE Framework than I had initially anticipated; though, this does seem to be doable.

*** ah yes, I see the helpful methods in SuperpoweredSimple, plus a host of conversion methods designed for use with SP. I had asked Superpowered what I would need minimally to get started with this integration, and they responded that you just need the static library file and the headers for the modules desired; although, prefaced this with the additional caveat that they were not personally familiar with the JUCE framework.