music-notation-swift / music-notation-core

Music Notation Library in Swift (Deprecated. See `music-notation` instead)
MIT License
115 stars 16 forks source link

Pull preserveTieState into helper #99

Open drumnkyle opened 8 years ago

drumnkyle commented 8 years ago

Tuplet.preserveTieStateForReplacement(in:with:) needs to be used in Measure replaceNotes methods. Therefore, this logic can be moved into a static function in a helper. That helper will only be static methods (this one for now), so it should be an enum so that it can't be instantiated. The method signature will need to look like this:

internal enum TieHelper {
    static func preserveTieState(of original: [NoteCollection], forReplacement replacement: [NoteCollection], in noteRange: CountableClosedRange<Int>) throws -> [NoteCollection]
}

Also, use this method in the spots where the TODO are in the Measure implementation and substitute usage of the Tuplet method. Tests also need to be written. You can look at Tuplet tests, because there are tests that covered this already.

drumnkyle commented 8 years ago

This is not as simple as we thought, because the note(at:) method used is different between a Measure and a NoteCollection. This should be revisited later. @migue48: please copy and paste as you have already done and leave that there for now. I will make this p2.