helge17 / tuxguitar

Improve TuxGuitar and provide builds
Other
481 stars 42 forks source link

Erroneous handling of tuplets (invalid measure duration) #118

Open guiv42 opened 1 year ago

guiv42 commented 1 year ago

Seen on 1.6.0, but most probably present since a long time (edit: present in 1.5.4)

The scenario below is really not critical and most users will never see this problem (time division 10:8 is not so frequent). However, I have already seen weird behaviors of TuxGuitar regarding tuplets (triolets, etc), that I could not always understand neither reproduce. And this issue (fully reproducible) shows clearly something is going wrong under the hood.

The following sequence leads to an invalid measure (start from default template):

  1. select duration 1/16h
  2. select triplet, time division 9
  3. select triplet, time division 10 => KO, the tuplet only contains 19 beats instead of 20, and the last beat takes an erroneous duration (1/64th) Practically, at this stage the TGDivisionType attribute of the last beat is set to an incorrect value: 1/64th, no time division (should be 1/16th, time division 10:8). Possibly one loop finishing 1 step too early when setting beats duration?

What is weird is that it depends from the previous operation. The following sequence is OK (still starting from default template):

  1. select duration 1/16h
  2. select triplet, time division 10 -> OK

This one is OK also

  1. select duration 1/16h
  2. select triplet, time division 11
  3. select triplet, time division 10 -> OK

https://github.com/helge17/tuxguitar/assets/129443524/ec449883-512e-4297-8035-65f5fe6107ee

Makoha commented 8 months ago

I have encountered some unexpected behavior which I assume is also related to this issue.

If you create a full bar of 13-tupleted 64'th nodes, TuxGuitar will display the bar as expected. billede

If you then go ahead and save the file and reopen it, an extra dotted 64'th node will be add to the bar. billede

I initially encountered this problem a couple a years ago using TuxGuitar 1.5.4, when I was doing an absurd project where a snare drum had to be played by some very specific intervals. Something like hitting every 7'th 13-tupleded 32'nd node. I managed to create full bars of various tuplets and insert the notes at the intended positions, but after saving the file and reopening it, I realized that some of the bars now contained these invalid measure durations.

Makoha commented 7 months ago

Yesterday I managed to setup Eclipse and run/build the source code. I am currently looking into this issue.

Makoha commented 7 months ago

I also discovered that if you try to create a full measure of 64th triplet notes, the measure will only contain 92 notes, instead of the expected 96 notes. I spotted that the last triplet grouping only contains 2 notes, but then realized that the measure also is missing an extra triplet grouping.

billede

A similar thing also occurs with sextuplets and 12-tuplets which I assume is related to both of them being multiples of 3.

guiv42 commented 7 months ago

Thank you very much @Makoha for PR #331. Do you think we should close this issue? (at least all explicit error scenarios described here seem to be fixed, as far as I could test)

guiv42 commented 4 months ago

Still some issues with tuplets: trying to set 9:8 time division should fail when there are less than 8 beats in bar

https://github.com/helge17/tuxguitar/assets/129443524/a38f2907-293f-471f-88fa-0ff8d8f9a157