music-notation-swift / music-notation-core

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

Incorrect number of ticks for tuplets #130

Closed massimobio closed 4 years ago

massimobio commented 6 years ago

We currently use an Int to measure the length of events with a fixed value of 2048 ticks per quarter note. While this covers most cases, there are situations where the length of the notes in a tuplet cannot be represented with an integer value of ticks. For example an eight note triplet is the length of a quarter note = 2048 ticks, and each note of the triplet is 2048/3 ticks = 682.666666.... which is currently rounded down to 682 and leads to an incorrect number of total ticks. There is a failing test that demonstrates this: testCumulativeTicksBeginningOfTuplet()