Class

AVAudioTime

This class is used by the audio engine to represent time.

Overview

Instances of this class are immutable.

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

A Boolean value that indicates 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

A Boolean value that indicates 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

First Steps

class AVAudioFile

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

class AVAudioBuffer

This class represents a buffer of audio data and its format.

Audio Settings and Formats

Constants and classes that define audio data.