I noticed that when parsing charts with 12ths or 24ths, the underlying Fraction representation for Beats are very strange.
Here's a minimal reproducing example where we parse an SM file with a single measure full of 12th notes and print the numerator and denominator of all Note objects:
You are passing a float to the Fraction constructor rather than a pair of integers. This will behave fine when the fraction is a power of two (since these can be represented exactly as floating-point values) but will give strange behavior when the fraction is not a power of two.
The fix is simple; you just need to use the Fraction constructor that accepts a pair of integers for the numerator and denominator. When run with --apply-patch=1, my test script above monkey-patches NoteData.__iter__ to apply this fix; this then gives a much more normal result when parsing the chart with 12th notes:
Thanks for the great package!
I noticed that when parsing charts with 12ths or 24ths, the underlying Fraction representation for Beats are very strange.
Here's a minimal reproducing example where we parse an SM file with a single measure full of 12th notes and print the numerator and denominator of all Note objects:
https://gist.github.com/jcjohnson/603d9b5ab50016429f762cf9a5db2af7
When run, it gives the output:
The problem is here: https://github.com/garcia/simfile/blob/master/simfile/notes/__init__.py#L169
You are passing a float to the Fraction constructor rather than a pair of integers. This will behave fine when the fraction is a power of two (since these can be represented exactly as floating-point values) but will give strange behavior when the fraction is not a power of two.
The fix is simple; you just need to use the Fraction constructor that accepts a pair of integers for the numerator and denominator. When run with
--apply-patch=1
, my test script above monkey-patchesNoteData.__iter__
to apply this fix; this then gives a much more normal result when parsing the chart with 12th notes: