Meter
public struct Meter
Abstract structure of beats which are concretely represented in a measure.
To create a basic meter, it is a simple as:
let common = Meter(4,4)
let waltz = Meter(3,4)
let ferneyhough = Meter(3,12)
A fractional meter can be created like so:
let fractional = Meter(Fraction(3,5),16)
Any number of meters can be combined into an additive meter:
let blueRondo = Meter(2,8) + Meter(2,8) + Meter(2,8) + Meter(3,8)
let czernowinSQm5 = Meter(Meter(1,4),Meter(3,16))
Basic and fractional meters can also be combined:
let czernowinSQm7 = Meter(Meter(1,4),Meter(Fraction(2,3),4))
-
A collection of contiguous
Metervalues indexed by their fractional offset.Example Usage
You can create a
Meter.Collectionin several different ways:With an array literal of
Metervalues:let _: Meter.Collection = [Meter(3,4), Meter(5,16), Meter(5,8)]With the standard initializer:
let _ = Meter.Collection([Meter(3,4), Meter(5,16), Meter(5,8)])You can also add an fractional offset, if needed:
let _ = Meter.Collection([Meter(3,4), Meter(5,16), Meter(5,8)], offset: Fraction(3,64))Lastly, you can construct a
Meter.Collectionover time with aMeterCollectionBuilder:let _ = MeterCollectionBuilder(offset: Fraction(21,16) .add(Meter(3,4) .add(Meter(2,4) .add(Meter(5,8) .add(Meter(13,64) .add(Meter(7,16) .build()To get a fragment of a
Meter.Collection, supply a desired range:let meters: Meter.Collection = [Meter(4,4), Meter(3,4), Meter(5,4)] let range = Fraction(7,16) ..< Fraction(31,16) let fragment = meters.fragment(in: range)This will return a collection of
Meter.Fragmentvalues in the given rage.Declaration
Swift
public typealias Collection = ContiguousSegmentCollection<Meter>
-
The context of a
See moreMeter.Fragmentin a container.Declaration
Swift
public struct Context : Equatable
-
Creates a
Meterwith the givenbeatsandsubdivision.Declaration
Swift
public init(_ beats: Int, _ subdivision: Int) -
Creates a fractional meter, with the given
fractionandsubdivision.Declaration
Swift
public init(_ fraction: Fraction, _ subdivision: Int) -
Creates a
Meterby aggregating all of the givenmeters.Declaration
Swift
public init<C>(_ meters: C) where C : Collection, C.Element == Meter
-
Declaration
Swift
public var beatOffsets: [Fraction] { get }Return Value
The offsets of each beat contained herein.
-
Declaration
Swift
public static var zero: Meter { get }Return Value
A
Meterwith no duration. -
Declaration
Swift
public static func + (lhs: Meter, rhs: Meter) -> MeterReturn Value
An additive meter composed of the two given meters.
-
Declaration
Swift
public static var one: Meter { get }Return Value
A
Meterwithbeatsandsubdivisionvalues of1. -
Declaration
Swift
public static func * (lhs: Meter, rhs: Meter) -> MeterReturn Value
The multiplicative product of the given meters.
-
Declaration
Swift
public var numerator: Int { get }Return Value
The
numeratorforRationalarithmetic. -
Declaration
Swift
public var denominator: Int { get }Return Value
The
denominatorforRationalarithmetic.
-
A
Meteris measured by aFraction.Declaration
Swift
public typealias Metric = Fraction -
Declaration
Swift
public var length: Fraction { get }Return Value
The fractional length of a
Meter.
-
Declaration
Swift
public func fragment(in range: Range<Fraction>) -> Meter.FragmentReturn Value
A
Meter.Fragmentin the givenrange.
-
Creates a
Meterwith the given amount ofbeatsover a subdivision of1.Declaration
Swift
public init(integerLiteral beats: Int)
View on GitHub
Install in Dash
Meter Structure Reference