mutableChannelData(_:)
Returns mutable access to a specific channel’s data.
Declaration
func mutableChannelData(_ index: Int) -> AVAudioPCMBuffer.MutableChannelDataParameters
- 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:
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
}
}