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
-
Numerator.
Declaration
Swift
public let beats: Beats
-
Denominator.
Declaration
Swift
public let subdivision: Subdivision
-
Create a
Duration
with abeats
andsubdivision
.Declaration
Swift
public init(_ numerator: Beats, _ denominator: Subdivision)
-
A
Duration
with zero length.Declaration
Swift
public static let zero: Duration
-
Declaration
Swift
public var numerator: Int { get }
Return Value
The
beats
value forRational
arithmetic. -
Declaration
Swift
public var denominator: Int { get }
Return Value
The
subdivision
value forRational
arithmetic.
-
Creates a
Duration
with the given amount ofbeats
at the quarter-note level.Declaration
Swift
public init(integerLiteral beats: Int)