---
title: "ExtAudioFileCreateWithURL(_:_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/extaudiofilecreatewithurl(_:_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.audiotoolbox/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 doc://com.apple.audiotoolbox/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

Return Value A result code.

## Discussion

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.

## See Also

### Managing Extended Audio File Objects

- [ExtAudioFileDispose(_:)](audiotoolbox/extaudiofiledispose(_:).md)
- [ExtAudioFileOpenURL(_:_:)](audiotoolbox/extaudiofileopenurl(_:_:).md)
- [ExtAudioFileWrapAudioFileID(_:_:_:)](audiotoolbox/extaudiofilewrapaudiofileid(_:_:_:).md)
