An audio file that can be opened for reading or writing.


class AVAudioFile : NSObject


Regardless of the file’s actual format, you read and write it using AVAudioPCMBuffer objects that contain samples using AVAudioCommonFormat. This format is referred to as the file’s processing format. Conversions are performed to and from the file’s actual format.

Reads and writes are always sequential, but random access is possible by setting the framePosition property.


Creating an Audio File

init(forReading: URL, commonFormat: AVAudioCommonFormat, interleaved: Bool)

Open a file for reading using a specified processing format.

init(forReading: URL)

Opens a file for reading.

Reading and Writing the Audio Buffer

Getting Audio File Properties

var fileFormat: AVAudioFormat

The on-disk format of the file.

var processingFormat: AVAudioFormat

The processing format of the file.

var framePosition: AVAudioFramePosition

The position in the file at which the next read or write operation will occur.

typealias AVAudioFramePosition

A position in an audio file or stream.

var length: AVAudioFramePosition

The number of sample frames in the file.

typealias AVAudioFrameCount

A number of audio sample frames.

var url: URL

The URL the file is reading or writing.

let AVAudioFileTypeKey: String

A string indicating the audio file type.


Inherits From

Conforms To

See Also

First Steps

class AVAudioBuffer

A buffer of audio data and its format.

class AVAudioTime

A class used by the audio engine to represent time.

Audio Settings and Formats

Define audio data with these constants and classes.

Enabling USB Audio and MIDI for iOS

Set up your system to record digital audio from an iOS device and exchange MIDI data with it by enabling Inter-Device Audio and MIDI.