<!--
{
  "availability" : [
    "iOS: 2.1.0 -",
    "iPadOS: 2.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/ExtAudioFileCreateWithURL(_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@ExtAudioFileCreateWithURL"
  },
  "title" : "ExtAudioFileCreateWithURL(_:_:_:_:_:_:)"
}
-->

# ExtAudioFileCreateWithURL(_:_:_:_:_:_:)

Creates a new audio file and associates it with a new extended audio file object.

```
func ExtAudioFileCreateWithURL(_ inURL: CFURL, _ inFileType: AudioFileTypeID, _ inStreamDesc: UnsafePointer<AudioStreamBasicDescription>, _ inChannelLayout: UnsafePointer<AudioChannelLayout>?, _ inFlags: UInt32, _ outExtAudioFile: UnsafeMutablePointer<ExtAudioFileRef?>) -> OSStatus
```

## Parameters

`inURL`

The URL of the new audio file.

`inFileType`

The type of file to create, specified as a constant from the [`AudioFileTypeID`](/documentation/AudioToolbox/AudioFileTypeID) enumeration.

`inStreamDesc`

The format of the audio data to be written to the file.

`inChannelLayout`

The channel layout of the audio data. If non-null, this must be consistent with the number of channels specified by the `inStreamDesc` parameter.

`inFlags`

Flags for creating or opening the file. If the [`eraseFile`](/documentation/AudioToolbox/AudioFileFlags/eraseFile) flag is set, it erases an existing file. If the flag is not set, the function fails fails if the URL points to an existing file.

`outExtAudioFile`

On output, a newly allocated extended audio file object.

## Return Value

A result code.

## Discussion

If the file to be created is in a compressed format, you may set the sample rate in the `inStreamDesc` parameter to `0`. In all cases, the extended file object’s encoding converter may produce audio at a different sample rate than the source. The file will be created with the audio format produced by the encoder.

---

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)