---
title: "mutableChannelData(_:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiopcmbuffer/mutablechanneldata(_:)"
---

# mutableChannelData(_:)

Returns mutable access to a specific channel’s data.

## Declaration

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

## Parameters

- `index`: The zero-based channel index.

## Return Value

Return Value A MutableChannelData enum containing the channel’s sample data.

## Discussion

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. 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     } }

## See Also

### Accessing PCM Buffer Data

- [channelData(_:)](avfaudio/avaudiopcmbuffer/channeldata(_:).md)
- [withUnsafeAudioBufferList(_:)](avfaudio/avaudiopcmbuffer/withunsafeaudiobufferlist(_:).md)
- [floatChannelData](avfaudio/avaudiopcmbuffer/floatchanneldata.md)
- [frameCapacity](avfaudio/avaudiopcmbuffer/framecapacity.md)
- [int16ChannelData](avfaudio/avaudiopcmbuffer/int16channeldata.md)
- [int32ChannelData](avfaudio/avaudiopcmbuffer/int32channeldata.md)
- [stride](avfaudio/avaudiopcmbuffer/stride.md)
- [AVAudioPCMBuffer.ChannelData](avfaudio/avaudiopcmbuffer/channeldata.md)
- [AVAudioPCMBuffer.MutableChannelData](avfaudio/avaudiopcmbuffer/mutablechanneldata.md)
