AudioBlock from const float** inputChannelData

I am using audioDeviceIOCallback(const float** inputChannelData, int numInputChannels, float** outputChannelData, int numOutputChannels, int numSamples) to implement my audio processing routine. I want to use the dsp::AudioBlock<float> object to use it with dsp::FIR::Filter to filter my input signal.
But because inputChannelData is const float** I can’t just do

dsp::AudioBlock<float> input{ inputChannelData, 1, blockSize };

What I coud do is

dsp::AudioBlock<float> input{ const_cast<float**>(inputChannelData), 1, blockSize };

but I wanted to ask, is there is a better way to reach my goal? :grinning:


I thought that the FIR filter would act destructively on the buffer you give it? In which case your const_cast is a really bad idea, because it’ll mean you’re modifying that data - and it’s marked as const because you’re not allowed to modify it!

Thanks for the fast response!
Is void dsp::FIR::Filter< SampleType >::process(const ProcessContext & context) modifying the input even if it is called with ProcessContextNonReplacing (const AudioBlockType &input, AudioBlockType &output)?

Yeah, that one would be safe to call. And yes, as long as you know that AudioBlock will be itself be const, then doing a const_cast to get the raw data into it is an annoying thing to have to do, but difficult to avoid.