XM amiga period calculation

Started by bass, December 20, 2015, 21:02:55

Previous topic - Next topic

bass

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!

Saga Musix

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.