# AudioBlock from const float\*\* inputChannelData

**URL:** <https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250>\
**Category:** Development\
**Created:** [June 25, 2018, 9:55am UTC](https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250 "2018-06-25T09:55:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinmate](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinmate/32/4430_2.png) [@martinmate](https://forum.juce.com/u/martinmate)\
**Post date:** [June 25, 2018, 9:55am UTC](https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250/1 "2018-06-25T09:55:19Z")

</div>

Hi,  
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

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

What I coud do is

```auto
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? 😀

Thanks!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 25, 2018, 9:58am UTC](https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250/2 "2018-06-25T09:58:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![martinmate](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinmate/32/4430_2.png) [@martinmate](https://forum.juce.com/u/martinmate)\
**Post date:** [June 25, 2018, 10:05am UTC](https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250/3 "2018-06-25T10:05:29Z")

</div>

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)`?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 25, 2018, 10:20am UTC](https://forum.juce.com/t/audioblock-from-const-float-inputchanneldata/28250/4 "2018-06-25T10:20:25Z")

</div>

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.
