digital-sound-antiques / libkss

A player library for MSX music formats.
Other
38 stars 6 forks source link

Playback rate fix #11

Closed gcielniak closed 1 year ago

gcielniak commented 1 year ago

Hi, thankyou for this great library! I have discovered that the music files converted with kss2vgm resulted in a slightly faster playback (~1.7%) when compared to the KSS files played on nezplug++. I traced back the problem to the current handling of the kmz80_exec() calls, which might actually take more Z80 cycles than requested. This difference results in a faster vsync rate and consequently a faster playback speed.

The two commits in this pull request address this issue by:

  1. fixing the calculation of step_inc so that it represents fractional values.
  2. compensating step_cnt by the extra cycles calculated from kmz80_exec(). This solution is very similar to the way nezplug++ handles the cycle execution.

I have checked the playback rate on a couple of songs from Snatcher which seems to be ok now. Please review and see if this is a good general fix. Thanks!

okaxaki commented 1 year ago

Hi, thank you for your pull request and sorry for the delay in replying.

I think your corrections are spot on. I also appreciate you adding your clarifying comments.

I will merge this PR. Thank you very much!