OPN F-Num to frequency formula
Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.
Moderator: Staff
- vampirefrog Offline
- Webmaster
- Posts: 1508
- Joined: 2014-01-28, 5:51:54
OPN F-Num to frequency formula
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
For OPN series this might work based on the datasheet (though really not tested):
For OPM you'll need a lookup table to convert the keycode to MIDI notes then you can do something like
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.
Code: Select all
Fc / 144 / 2^(10-Block) * Fnum / 2048
8000000 / 144 / Math.pow(2,10-4) * 1038 / 2048 = 439.9617513020833
Code: Select all
440 * 2^((kc - 56 + kf / 64)/12)
- vampirefrog Offline
- Webmaster
- Posts: 1508
- Joined: 2014-01-28, 5:51:54