I’d like to take the firsts channels from an AudioBuffer in another one without copying them, is this possible? or will I do something wrong?
AudioSampleBuffer ab {12, 1024};
AudioSampleBuffer section {ab.getArrayOfWritePointers(), 2, 512, 128};
Or using AudioBuffer::setDataToReferTo() (but I think it’s the same)
Edit: I know the AudioBuffer description states that the number of channel must be the same that its source, but maybe it’s still possible since I’m using only the first ones
I know it’s an old post but since it got resurrected…
yes, that is absolutely possible. You just need to adapt the array and possibly reorder the pointers to you needs (like @jamiebullock described above).
In general if you can, change the interface to juce::dsp::AudioBuffer. That makes it easier:
AudioSampleBuffer ab {12, 1024};
auto section = juce::dsp::AudioBlock (ab).getSubBlock (512, 128);
juce::dsp::AudioBlock doesn’t own sample data hence it doesn’t allocate and you can copy it around as you like it (with one exception, if you construct it giving it a juce::HeapBlock).