<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioConverter/convert(to:error:withInputFrom:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioConverter(im)convertToBuffer:error:withInputFromBlock:"
  },
  "title" : "convert(to:error:withInputFrom:)"
}
-->

# convert(to:error:withInputFrom:)

Performs a conversion between audio formats, if the system supports it.

```
func convert(to outputBuffer: AVAudioBuffer, error outError: NSErrorPointer, withInputFrom inputBlock: (AVAudioPacketCount, UnsafeMutablePointer<AVAudioConverterInputStatus>) -> AVAudioBuffer?) -> AVAudioConverterOutputStatus
```

## Parameters

`outputBuffer`

The output audio buffer.

`outError`

The error if the conversion fails.

`inputBlock`

A block the framework calls to get input data.

## Return Value

An [`AVAudioConverterOutputStatus`](/documentation/AVFAudio/AVAudioConverterOutputStatus) type that indicates the conversion status.

## Discussion

The method attempts to fill the buffer to its capacity. On return, the buffer’s length indicates the number of sample frames the framework successfully converts.

## Topics

### Callbacks

[`AVAudioConverterInputBlock`](/documentation/AVFAudio/AVAudioConverterInputBlock)

A block to get input data for conversion, as necessary.



---

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)