---
title: "copyPCMData(fromRange:into:)"
framework: coremedia
role: symbol
role_heading: Instance Method
path: "coremedia/cmsamplebuffer/copypcmdata(fromrange:into:)"
---

# copyPCMData(fromRange:into:)

Copies PCM audio data from a sample buffer into a prepopulated audio buffer list.

## Declaration

```swift
func copyPCMData(fromRange range: Range<Int>, into bufferList: UnsafeMutablePointer<AudioBufferList>) throws
```

## Parameters

- `range`: The range of the data buffer to copy from.
- `bufferList`: The audio buffer list to populate.

## Discussion

Discussion The audio buffer list must contain the same number of channels, and must be appropriately sized for its data buffers to hold the specified number of frames. This API is specific to audio format sample buffers, and throws an invalidMediaTypeForOperation if called with a nonaudio sample buffer. Likewise, this method throws an error if the sample buffer doesn’t contain PCM audio data or if its data buffer isn’t ready.

## See Also

### Modifying Sample Buffers

- [dataBuffer](coremedia/cmsamplebuffer/databuffer.md)
- [setDataBuffer(_:)](coremedia/cmsamplebuffer/setdatabuffer(_:).md)
- [imageBuffer](coremedia/cmsamplebuffer/imagebuffer.md)
- [withAudioBufferList(blockBufferMemoryAllocator:flags:body:)](coremedia/cmsamplebuffer/withaudiobufferlist(blockbuffermemoryallocator:flags:body:).md)
- [setDataBuffer(fromAudioBufferList:blockBufferMemoryAllocator:flags:)](coremedia/cmsamplebuffer/setdatabuffer(fromaudiobufferlist:blockbuffermemoryallocator:flags:).md)
- [audioStreamPacketDescriptions()](coremedia/cmsamplebuffer/audiostreampacketdescriptions().md)
- [withUnsafeAudioStreamPacketDescriptions(_:)](coremedia/cmsamplebuffer/withunsafeaudiostreampacketdescriptions(_:).md)
- [singleSampleBuffers()](coremedia/cmsamplebuffer/singlesamplebuffers().md)
- [CMSampleBuffer.SingleSampleBuffers](coremedia/cmsamplebuffer/singlesamplebuffers.md)
