Class

AVAudioFile

The AVAudioFile class represents an audio file that can be opened for reading or writing.

Overview

Regardless of the file’s actual format, you read and write the file using AVAudioPCMBuffer objects, that contain samples in AVAudioCommonFormat, 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.

Topics

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 framePosition: AVAudioFramePosition

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

var length: AVAudioFramePosition

The number of sample frames in the file.

var processingFormat: AVAudioFormat

The processing format of the file.

var url: URL

The URL the file is reading or writing.

Relationships

Inherits From

Conforms To

See Also

Format and File Settings

class AVAudioFormat

The AVAudioFormat class wraps a Core Audio AudioStreamBasicDescription struct, with convenience initializers and accessors for common formats, including Core Audio’s standard deinterleaved 32-bit floating point format.

Linear PCM Format Settings

Audio settings that apply to linear PCM audio formats.