Geromatic / Midi-Unreal

Midi for Unreal Engine
129 stars 31 forks source link

MidiUtil::ticksToMs has long/int conversion problems #3

Closed stani closed 7 years ago

stani commented 7 years ago
long k = MidiUtil::ticksToMs(122456L, 454545, 120);
UE_LOG(LogTemp, Warning, TEXT("%ld"), k);

result: -1440

Geromatic commented 7 years ago

time should always be unsigned.

long ticksToMs(long ticks, int mpqn, int resolution) { return ((ticks * (mpqn & 0x00000000ffffffffL)) / resolution) / 1000; }

stani commented 7 years ago

Still something wrong with the new formula.

ticksToMs(9432,454545,120) -> 35727
ticksToMs(9452,454545,120) -> 11

conversion may have fixed playback speed of midi.

ticksToMs is not used anywhere in the plugin, only msToTicks is used

Geromatic commented 7 years ago

seemed i confused myself with the other. anyway I forced value to do a unsigned long long. Seems like the multiplication is causing a value overflow

stani commented 7 years ago

Works good.