Class

AVAudioTime

The AVAudioTime class is used by AVAudioEngine to represent time. Instances of the class are immutable.

Overview

A single moment in time may be represented in two different ways:

  • Using mach_absolute_time(), the system's basic clock. Referred to as “host time.”

  • Audio samples at a particular sample rate.

A single AVAudioTime instance may contain either or both representations; it might represent only a sample time, only a host time, or both.

Topics

Creating an Audio Time Instance

init(audioTimeStamp: UnsafePointer<AudioTimeStamp>, sampleRate: Double)

Initializes a new audio time object with the AudioTimeStamp struct and sample rate.

init(hostTime: UInt64)

Initializes a new audio time object with the specified host time.

init(hostTime: UInt64, sampleTime: AVAudioFramePosition, atRate: Double)

Initializes a new audio time object with the specified host time, sample time, and sample rate.

init(sampleTime: AVAudioFramePosition, atRate: Double)

Initializes a new audio time object with the specified AudioTimeStamp struct and sample rate.

func extrapolateTime(fromAnchor: AVAudioTime)

Creates an audio time object by converting between host and sample time.

Manipulating Host Time

var hostTime: UInt64

The host time.

var isHostTimeValid: Bool

Whether the host time value is valid.

class func hostTime(forSeconds: TimeInterval)

Converts seconds to host time.

class func seconds(forHostTime: UInt64)

Converts host time to seconds.

Getting Sample Rate Information

var sampleRate: Double

The sample rate at which the sample time is being expressed.

var sampleTime: AVAudioFramePosition

The time as a number of audio samples, as tracked by the current audio device.

var isSampleTimeValid: Bool

Whether the sample time and sample rate properties are valid.

Getting the CoreAudio Time Stamp

var audioTimeStamp: AudioTimeStamp

The time expressed as an AudioTimeStamp structure.

Relationships

Inherits From

Conforms To

See Also

Audio Helpers

class AVAudioChannelLayout

The AVAudioChannelLayout class describes the roles of a set of audio channels.