incorrect tempo change handling
derselbst opened this issue · comments
Having a lot of tempo changes throws fluidsynth off-timing somewhy (compared to timidity and audacity midi parsing).
Attached file is one case where it happens. file1.midi has repeated tempo change tags that all change it to the exact same value. file2.midi has just the first of them. Effectively, they should be synthesized to the same audio, but in practice file1 is longer.
Reported by: velochy
Original Ticket: fluidsynth/tickets/143
Here's the problem:
fluidsynth/fluidsynth/src/midi/fluid_midi.c
Lines 1625 to 1627 in 174d855
It does a floating point calculation of the time diff between now and the last tempo change event. The result is then casted to int, every such cast results in an error. For file1.mid
start_msec
gets updated frequently and the error seems to increase, as start_msec
is nearly the same as cur_msec
.
Currently dont know how to fix this properly.
For 1.1.7 the time diff after about 1.5 minutes of playback is about 0.15 seconds between the two files. For 1.1.6 the diff was 0.26 seconds. I dont think we can get it any better without rewriting fluid_player
and I dont see this to happen soon. Closing for now.
Here are the test files for later reference.
testfiles.zip