AKDuration

public struct AKDuration: CustomStringConvertible, Comparable

Container for the notion of time in sequencing

  • Duration in beats

    Declaration

    Swift

    public var beats: Double
  • Samples per second

    Declaration

    Swift

    public var sampleRate: Double = 44_100
  • Tempo in BPM (beats per minute)

    Declaration

    Swift

    public var tempo: BPM = 60.0
  • While samples is the most accurate, they blow up too fast, so using beat as standard

    Declaration

    Swift

    public var samples: Int
  • Regular time measurement

    Declaration

    Swift

    public var seconds: Double
  • Useful for math using tempo in BPM (beats per minute)

    Declaration

    Swift

    public var minutes: Double
  • Music time stamp for the duration in beats

    Declaration

    Swift

    public var musicTimeStamp: MusicTimeStamp
  • Pretty printout

    Declaration

    Swift

    public var description: String
  • Initialize with samples

    Declaration

    Swift

    public init(samples: Int, sampleRate: Double = 44_100, tempo: BPM = 60)

    Parameters

    samples

    Number of samples

    sampleRate

    Sample rate in samples per second

  • Initialize from a beat perspective

    Declaration

    Swift

    public init(beats: Double, tempo: BPM = 60)

    Parameters

    beats

    Duration in beats

    tempo

    AKDurations per minute

  • Initialize from a normal time perspective

    Declaration

    Swift

    public init(seconds: Double, sampleRate: Double = 44_100, tempo: BPM = 60)

    Parameters

    seconds

    Duration in seconds

    sampleRate

    Samples per second (Default: 44100)

  • Add to a duration

    Declaration

    Swift

    public static func += (lhs: inout AKDuration, rhs: AKDuration)

    Parameters

    lhs

    Starting duration

    rhs

    Amount to add

  • Subtract from a duration

    Declaration

    Swift

    public static func -= (lhs: inout AKDuration, rhs: AKDuration)

    Parameters

    lhs

    Starting duration

    rhs

    Amount to subtract

  • Duration equality

    Declaration

    Swift

    public static func ==(lhs: AKDuration, rhs: AKDuration) -> Bool

    Parameters

    lhs

    One duration

    rhs

    Another duration

  • Duration less than

    Declaration

    Swift

    public static func < (lhs: AKDuration, rhs: AKDuration) -> Bool

    Parameters

    lhs

    One duration

    rhs

    Another duration

  • Adding durations

    Declaration

    Swift

    public static func + (lhs: AKDuration, rhs: AKDuration) -> AKDuration

    Parameters

    lhs

    One duration

    rhs

    Another duration

  • Subtracting durations

    Declaration

    Swift

    public static func - (lhs: AKDuration, rhs: AKDuration) -> AKDuration

    Parameters

    lhs

    One duration

    rhs

    Another duration

  • Modulus of the duration’s beats

    Declaration

    Swift

    public static func % (lhs: AKDuration, rhs: AKDuration) -> AKDuration

    Parameters

    lhs

    One duration

    rhs

    Another duration