AKTiming

@objc
public protocol AKTiming

A timing protocol used for syncronizing different audio sources.

  • Starts playback at a specific time.

    Declaration

    Swift

    @objc
    func start(at audioTime: AVAudioTime?)

    Parameters

    audioTime

    A time in the audio render context.

  • Stops playback immediately.

    Declaration

    Swift

    @objc
    func stop()
  • Declaration

    Swift

    var isStarted: Bool { get }
  • Set position in playback timeline (seconds).

    Declaration

    Swift

    @objc
    func setPosition(_ position: Double)
  • Timeline time at an audio time

    • Return: Position in the timeline context (seconds).

    Declaration

    Swift

    @objc(positionAtAudioTime:)
    func position(at audioTime: AVAudioTime?) -> Double

    Parameters

    audioTime

    A time in the audio render context.

  • Audio time at timeline time

    • Return: A time in the audio render context.

    Declaration

    Swift

    @objc(audioTimeAtPosition:)
    func audioTime(at position: Double) -> AVAudioTime?

    Parameters

    position

    Time in the timeline context (seconds).

  • Prepare for playback. After prepare has been called, the node should be ready to begine playback immediately. Any time consuming operations necessary for playback (eg. disk reads) should be complete once prepare has been called.

    Declaration

    Swift

    @objc
    optional func prepare()
  • syncStart(_:at:) Extension method

    Starts an array of AKTimings at a position.

    Nodes are stopped, positions are set, then prepare is called (optional) on each node to allow for time consuming activities like reading from disk or buffering. Then, a future time is calculated using the last render timestamp (or now) + 2 render cycles to ensure synchronous start.

    Declaration

    Swift

    public static func syncStart(_ nodes: [AKTiming], at position: Double = 0) -> AVAudioTime

    Parameters

    nodes

    The nodes that will be synchronously started.

    position

    The position of the nodes when started.

    Return Value

    The audioTime (in the future) that the nodes will be started at.

  • synchronizeWith(other:at:) Extension method

    Starts playback with position synchronized to an already running node.

    Declaration

    Swift

    public func synchronizeWith(other: AKTiming, at audioTime: AVAudioTime? = nil)

    Parameters

    other

    An already started AKTiming that position will be synchronized with.

    audioTime

    Future time in the audio render context that playback should begin.