<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioPCMBuffer/mutableChannelData(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "s:So16AVAudioPCMBufferC8AVFAudioE18mutableChannelDatayAbCE07MutableeF0OSiF"
  },
  "title" : "mutableChannelData(_:)"
}
-->

# mutableChannelData(_:)

Returns mutable access to a specific channel’s data.

```
func mutableChannelData(_ index: Int) -> AVAudioPCMBuffer.MutableChannelData
```

## Parameters

`index`

The zero-based channel index.

## Return Value

A `MutableChannelData` enum containing the channel’s sample data.

## Discussion

The returned `MutableChannelData` is tied to the lifetime of this buffer and provides
type-safe mutable access to the channel’s sample data.

- Example:

> Warning: This function cannot enforce exclusivity at compile time because `AVAudioPCMBuffer`
> is an Objective-C class. The caller must ensure they don’t create overlapping mutable views
> to the same memory. It is safe to access different channels simultaneously or different
> regions of the same channel.

> Note: Provides access to the entire buffer (up to `frameCapacity`). frameLength needs to be updated if the size changes.

```swift
for channelIndex in 0..<Int(buffer.format.channelCount) {
    switch buffer.mutableChannelData(channelIndex) {
    case .float(var samples):
        // Modify Float32 data
        for frame in 0..<samples.count {
            samples[frame] = 0.0
        }
    case .int16(var samples):
        // Modify Int16 data
    case .int32(var samples):
        // Modify Int32 data
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)