Rhythm

public struct Rhythm<Element>

Undocumented

  • Hierarchical representation of metrical durations.

    Declaration

    Swift

    public let durationTree: DurationTree
  • Leaf items containing metrical context.

    Declaration

    Swift

    public var leaves: [Leaf]
  • The metrical identity of a given rhythmic leaf item.

    • tied: if a leaf is tied over from the previous event (.continuation)
    • rest: if a leaf is a rest, a measured silence (.instance(.rest))
    • event: if a leaf is a measured non-silence (.instance(.event(Element)))

    Declaration

    Swift

    public typealias Context = ContinuationOrInstance<AbsenceOrEvent<Element>>
  • Create a Rhythm with a given durationTree and given leaves.

    Declaration

    Swift

    public init(_ durationTree: DurationTree, _ leaves: [Context])
  • Create a Rhythm with a given duration and `leaves.

    Declaration

    Swift

    public init(_ duration: Duration, _ leaves: [(duration: Int, context: Context)])
  • Create an isochronic Rhythm with the given duration and the given contexts.

    Declaration

    Swift

    public init(_ duration: Duration, _ contexts: [Context])
  • Creates a Rhythm with a single event with the given context.

    Declaration

    Swift

    public init(_ duration: Duration, _ context: Context)
  • Declaration

    Swift

    public var events: [Element] { get }

    Return Value

    An array of the event values contained herein.

  • Declaration

    Swift

    public var duratedEvents: AnySequence<(Duration, Element)> { get }

    Return Value

    A sequence of tuples containing the Duration and Element information of event.

  • Declaration

    Swift

    public var eventOffsets: [Duration] { get }

    Return Value

    The durational offsets of the event-containing leaves.

  • Declaration

    Swift

    @inlinable
    public var lengths: [Duration] { get }

    Return Value

    The effective duration of each event.

  • Declaration

    Swift

    public var eventIndices: [Int] { get }

    Return Value

    The indices within leaves which contain events (not ties or rests).

    • Each .continuation remains as such

    • Each .instance(.rest) remains as such

    • Each .instance(.event(T)) is transformed to a .instance(.event(U))

    Declaration

    Swift

    public func map <U> (_ transform: @escaping (Element) -> U) -> Rhythm<U>

    Return Value

    Rhythm with each of its event (i.e., .instance(.event(Element))) values updated by the given transform.

  • Declaration

    Swift

    public func mapEvents<U>(_ transforms: [(Element) -> U]) -> Rhythm<U>

    Return Value

    Rhythm with each of the transforms applied to each of the event-containing leaves contained herein.

  • Declaration

    Swift

    public func replaceEvents<U>(_ events: [U]) -> Rhythm<U>

    Return Value

    Rhythm with the equivalent durationTree but with event-holding leaves replaced by the values contained in the given leaves.