dn-m / Music

Structures for the creation, analysis, and performance of music in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Meter] Lift Meter to protocol

jsbean opened this issue · comments

Currently, there is a Meter structure, which should expand to allow #52 and #53.

Lift Meter to a protocol:

protocol MeterProtocol: DurationSpanning, Fragmentable where Fragment: Meter {
    var length: Fraction
    var beatOffsets: [Fraction]
}

Then implement the current Meter accordingly:

struct Meter: MeterProtocol {
    var length: Fraction { ... }
    var beatOffsets: [Fraction] { ... }
}

This will leave room to implement AdditiveMeter and FractionalMeter:

extension Meter {
    struct Additive: MeterProtocol {
         ...
    }
    struct Fractional: MeterProtocol {
        ...
    }    
}

This will be critical for Meter.Collection to glide along smoothly:

extension Meter {
    struct Collection <MeterType: MeterProtocol> {
         let base: SortedDictionary<Fraction,MeterProtocol.Fragment>    
    }
}