Duration

public struct Duration

A unit of hierarchically-divided symbolic time.

Example Usage

You can create a Duration value with an amount of beats at a given subdivision level.

let _ = Duration(1,4) // => one quarter note
let _ = Duration(3,32) // => three thirty-second notes

You can also create a Duration value with an infix operator:

let _ = 3/>32
let _ = 31/>4

The subdivision value must be a power-of-two, otherwise your program will crash!

let _ = Duration(3,13) // boom
  • A Duration with zero length.

    Declaration

    Swift

    public static let zero: Duration
  • Declaration

    Swift

    public var numerator: Int { get }

    Return Value

    The beats value for Rational arithmetic.

  • Declaration

    Swift

    public var denominator: Int { get }

    Return Value

    The subdivision value for Rational arithmetic.

  • Creates a Duration with the given amount of beats at the quarter-note level.

    Declaration

    Swift

    public init(integerLiteral beats: Int)