# dsp::AudioBlock copyFrom/copyTo specific channel?

**URL:** <https://forum.juce.com/t/dsp-audioblock-copyfrom-copyto-specific-channel/46598>\
**Category:** Feature Requests\
**Created:** [June 22, 2021, 9:49am UTC](https://forum.juce.com/t/dsp-audioblock-copyfrom-copyto-specific-channel/46598 "2021-06-22T09:49:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![static-cats](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/static-cats/32/11285_2.png) [@static-cats](https://forum.juce.com/u/static-cats)\
**Post date:** [June 22, 2021, 9:49am UTC](https://forum.juce.com/t/dsp-audioblock-copyfrom-copyto-specific-channel/46598/1 "2021-06-22T09:49:22Z")

</div>

Hi all,

I think the `AudioBlock` lacks `copyFrom` and `copyTo` versions where you can specifiy the source and destination channel, similarly to the `AudioBuffer` class. If i want to do it right now i think i’d need to do some plumbing by creating temporary `AudioBlock`s pointing to what i want and call `copyFrom`/`copyTo` on those?

Would it be possible to add something like this in the future or am i missing something obvious ?

Cheers

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [June 22, 2021, 1:48pm UTC](https://forum.juce.com/t/dsp-audioblock-copyfrom-copyto-specific-channel/46598/2 "2021-06-22T13:48:01Z")

</div>

just use getSingleChannelBlock to access the single channel blocks, don’t worry about performance, because the methods are all visible to the compiler, it should be optimised very efficent.

BTW: I made a copyFrom-wrapper for some legacy code which uses now AudioBlocks instead of AudioBuffer

```auto
static void copyFrom (dsp::AudioBlock<FloatType> &dest,
					int destChannel,
                   int destStartSample,
                   const dsp::AudioBlock<const FloatType> source,
                   int sourceChannel,
                   int sourceStartSample,
                   int numSamples)
    {
        dest.getSingleChannelBlock (destChannel).getSubBlock (destStartSample, numSamples).copyFrom (source.getSingleChannelBlock (sourceChannel).getSubBlock (sourceStartSample, numSamples));
    }

```

---

<div class="post-metadata">

**Author:** ![static-cats](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/static-cats/32/11285_2.png) [@static-cats](https://forum.juce.com/u/static-cats)\
**Post date:** [June 22, 2021, 2:08pm UTC](https://forum.juce.com/t/dsp-audioblock-copyfrom-copyto-specific-channel/46598/3 "2021-06-22T14:08:29Z")

</div>

ah yep, that does the trick, cheers.
