*FR* 2 urgently needed functions for AudioBlock (code inside)



Provide quick-access to the channel array (quite useful if you have processing routines which need this format)

/** Returns raw pointers to channels in this block. */
forcedinline SampleType* const* getArrayOfChannelPointers() const noexcept
	return channels;

process Block with two inputs into one output Block

template <typename FunctionType>
static void process(const AudioBlock<SampleType>& inBlock1, const AudioBlock<SampleType>& inBlock2,
	AudioBlock<SampleType>& outBlock,
	const FunctionType& function)
	auto len = inBlock1.getNumSamples();
	auto numChans = inBlock1.getNumChannels();

	for (ChannelCountType c = 0; c < numChans; ++c)
		auto* src1 = inBlock1.getChannelPointer(c);
		auto* src2 = inBlock2.getChannelPointer(c);
		auto* dst = outBlock.getChannelPointer(c);

		for (size_t i = 0; i < len; ++i)
			dst[i] = function(src1[i],src2[i]);


Thanks, good request, I’ll sort that out…


Hang on, no… That’s not how it’s supposed to be used. The channels array doesn’t contain pointers to the start of each channel, you’d need to take into account the startSample value which needs to be added to each one. Just returning a raw array like that would be very easy to use incorrectly.


Well yes, you are right. Even if that means i must elaborately create such a array for third party functions.

But the second function (process with two inputs) , would be nice!


Sorry, I’m not sure I understand what you’re asking for with the second bit… You’re suggesting that should be an AudioBlock method? Why not just use your own free function?

Why not just use your own free function?
  • its a common task (modulate one audio stream with a another)
  • maybe you can write it better(faster) than me :wink:
  • so this thread isn’t useless
  • maybe other people use it and become happy

Of course, i could use my own free function, i could also use my own library, but i prefer not to :wink:


for the case you missed it, there is a process method already in AudioBlock

By the way, why does the process uses references, i think AudioBlock is more a copyByValue-Class.

The problem is that when it references, you can’t use the AudioBlock-Constructor in the parameters, Visual Studio warns because of non-standard conversion, because references have to be used with L-values.


dsp::AudioBlock<SampleType>::ChannelCountType is private
to create a free function, this has to be public