Segfault when pushing buffers with chanOffset using IBufferSender

Hi ! First of all, great library ! I was developing my plugin on the vst3sdk and rewriting my plugin using this library really made my life easier !

So for my plugin, I wanted to add a waveform analyzer to graph both inputs and outputs buffers, so to integrate that I used an IBufferSender<4> to send all channels to my IControl,

Though when sending in ProcessBlock I get a segmentation fault when doing

// have to call SetBufferSize every time before ProcessBlock to reset mBufCount ?
this->waveformViewSender.ProcessBlock(inputs, nFrames, kWaveformAnalizer, 2, 0);

// segfault on this call
this->waveformViewSender.ProcessBlock(outputs, nFrames, kWaveformAnalizer, 2, 2);

Which happens because of the way input buffers are copied into mBuffer of IBufferSender (in ISender.h on ProcessBlock definition of IBufferSender)

for (auto c = chanOffset; c < (chanOffset + nChans); c++)
    const float inputSample = static_cast<float>(inputs[c][s]);
    mBuffer.vals[c][mBufCount] = inputSample;        // ^ 
                                                     // inputs are not offset by chanOffset, 
                                                     // should be inputs[c - chanOffset][s] ?
    mRunningSum[c] += std::fabs(inputSample);

So at this point I am wondering that I may be doing something not intended with the library, however I cant figure out how to send both inputs and outputs with a single IBufferSender<4> or even using two IBufferSender<2>, I don’t know how to differentiate them in the OnMsgFromDelegate since I can’t edit their msgTag (which is always kMessageUpdate, would be nice if we could change it like in a template param)

I ended up copying the IBufferSender class, and added the c - chanOffset and it works perfectly.

Another problem I had was that when no audio is playing, I don’t receive the message (because sum of samples is smaller than mThreshold), which is great because it does not sends unnecessary data, however I could not figure out a way to flush my waveform data buffer in the IControl class since no data is pushed to the buffer (the waveform was “paused” when no audio was playing).

To fix that I edited again the IBufferSender class to return the number of samples that were skipped when no audio is playing

if (sum > mThreshold || mPreviousSum > mThreshold)
    // ... pushes back mBuffer using ISender::PushData
    mNSamplesSkipped += mBufCount; // mNSamplesSkipped is returned and reset to 0 in SetBufferSize

and then send a message when samples are skipped containing the number of samples that were skipped in the data, this way I can shift my waveform data buffer by the number of samples on OnMsgFromDelegate.

I didn’t want to make a github issue since I am about sure that I am not using the library correctly, still I wanted to report those issues I had and maybe someone would give me an answer for my problem without actually having to change the IBufferSender class.