Author Topic: XM amiga period calculation  (Read 964 times)

Offline bass

  • Shy artist
  • Posts: 6
XM amiga period calculation
« on: December 20, 2015, 21:02:55 »
Hi,

I´m trying to implement the XM format for my player and I have a question about the format.
In the document of Triton, the period for amiga frequence is calculated like this:

Period = (PeriodTab[(Note MOD 12)*8 + FineTune/16]*(1-Frac(FineTune/16)) +
        PeriodTab[(Note MOD 12)*8 + FineTune/16]*(Frac(FineTune/16)))
       *16/2^(Note DIV 12);

There are some errors in this formula, I think. One is, that I get negative values for PeriodTab when Finetune is negative. Should I take the first value in the PeriodTab then? Is there an easier formula for this perhaps?

Thx!

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,114
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Re: XM amiga period calculation
« Reply #1 on: December 20, 2015, 23:51:56 »
Treating finetune to be 0...255 instead of -128...127 should probably help with the negative values.
I think the formula in the FT2 docs should be correct but you can double-check by looking at what OpenMPT does in Snd_fx.cpp, namely in GetPeriodFromNote and GetFreqFromPeriod in the MOD_TYPE_XM cases. There are some gotchas documented there that are not obvious at all from any documentation, and they result in very weird behaviour in frequency calculation that is supported by few XM players.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.