Skip to content

OPN F-Num to frequency formula

Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.

Moderator: Staff

OPN F-Num to frequency formula

Post by vampirefrog »

Y'all happen to have a formula or some code that converts from the OPN Block + F-Num to a floating point frequency value? And maybe the same for OPM? Thanks
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

For OPN series this might work based on the datasheet (though really not tested):

Code: Select all

Fc / 144 / 2^(10-Block) * Fnum / 2048

8000000 / 144 / Math.pow(2,10-4) * 1038 / 2048 = 439.9617513020833
For OPM you'll need a lookup table to convert the keycode to MIDI notes then you can do something like

Code: Select all

440 * 2^((kc - 56 + kf / 64)/12)
this example assumes note count starts at C#0 and A4 freq is 440hz. For this you might need to define a different reference frequency based on the chip clock. If you want to be completely accurate you need to use yet another lookup table that converts it to the internal F-num/block.

Post by vampirefrog »

Thx, that seems to work for OPN, haven't tried the OPM formula yet.
Post Reply