<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioFile",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioFile"
  },
  "title" : "AVAudioFile"
}
-->

# AVAudioFile

An object that represents an audio file that the system can open for reading or writing.

```
class AVAudioFile
```

## Overview

Regardless of the file format, you read and write using [`AVAudioPCMBuffer`](/documentation/AVFAudio/AVAudioPCMBuffer) objects. These objects contain samples as [`AVAudioCommonFormat`](/documentation/AVFAudio/AVAudioCommonFormat) that the framework refers to as the file’s processing format. You convert to and from using the file’s actual format.

Reads and writes are always sequential. Random access is possible by setting the [`framePosition`](/documentation/AVFAudio/AVAudioFile/framePosition) property.

## Topics

### Creating an Audio File

[`init(forReading:)`](/documentation/AVFAudio/AVAudioFile/init(forReading:))

Opens a file for reading using the standard, deinterleaved floating point format.

[`init(forReading:commonFormat:interleaved:)`](/documentation/AVFAudio/AVAudioFile/init(forReading:commonFormat:interleaved:))

Opens a file for reading using the specified processing format.

[`init(forWriting:settings:)`](/documentation/AVFAudio/AVAudioFile/init(forWriting:settings:))

Opens a file for writing using the specified settings.

[`init(forWriting:settings:commonFormat:interleaved:)`](/documentation/AVFAudio/AVAudioFile/init(forWriting:settings:commonFormat:interleaved:))

Opens a file for writing using a specified processing format and settings.

### Reading and Writing the Audio Buffer

[`read(into:)`](/documentation/AVFAudio/AVAudioFile/read(into:))

Reads an entire audio buffer.

[`read(into:frameCount:)`](/documentation/AVFAudio/AVAudioFile/read(into:frameCount:))

Reads a portion of an audio buffer using the number of frames you specify.

[`read(frameCount:)`](/documentation/AVFAudio/AVAudioFile/read(frameCount:))

[`close()`](/documentation/AVFAudio/AVAudioFile/close())

Closes the audio file.

### Getting Audio File Properties

[`url`](/documentation/AVFAudio/AVAudioFile/url)

The location of the audio file.

[`fileFormat`](/documentation/AVFAudio/AVAudioFile/fileFormat)

The on-disk format of the file.

[`processingFormat`](/documentation/AVFAudio/AVAudioFile/processingFormat)

The processing format of the file.

[`length`](/documentation/AVFAudio/AVAudioFile/length)

The number of sample frames in the file.

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

A position in an audio file or stream.

[`framePosition`](/documentation/AVFAudio/AVAudioFile/framePosition)

The position in the file where the next read or write operation occurs.

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

A number of audio sample frames.

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

A string that indicates the audio file type.

[`isOpen`](/documentation/AVFAudio/AVAudioFile/isOpen)

A Boolean value that indicates whether the file is open.



---

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)