VOGONS


OPL fnum calculation

Topic actions

First post, by buzzy

User metadata
Rank Newbie
Rank
Newbie

Hello all, first post here so if its in the wrong place, please be nice 😀

OK, I am trying to work out frequency to OPL fnum, according to what I have read the formula is:
fnum = frequency * 2^(20-block)/49716.

Using a spreadsheet, I get the same numbers for each octave, is there a table of the best fnum values to use somewhere or can someone please explain what I am doing wrong?

Thanks a lot.

Buzzy

Reply 1 of 3, by jwt27

User metadata
Rank Oldbie
Rank
Oldbie

This may provide some insight in how the BLOCK/FNUM system was meant to be used: http://www.shikadi.net/moddingwiki/Talk:OPL_chip

Basically FNUM should stay the same for each note, while BLOCK and MULT change the octave.

Reply 2 of 3, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

Best FNUM values depend on what you are going to do, but FNUM values do not depend on octave (block), unless you want to go below octave (block) 0 so the you have to halve the FNUM for example. I would reserve the MULT multiplier as timbral characteristic for an instrument instead of using it for setting octave. So basically each instrument could span only 8 octaves, but the multiplier defines the "base" octave.

The chip has a setting for what range of FNUM values you would like to use so it knows how to interpret the FNUM values within an octave to correctly apply rate correction.

I would use 14318180/288 as the Fs in a spreadsheet, and of course 440Hz is the A4 frequency, so this makes A note as FNUM 580.

Basically the higher values you use the closer you get to the actual note frequency. So thus I would use the FNUM range of 512 to 1023 for an octave.
Thus the values are : 517,547,580,615,651,690,731,774,820,869,921,975
But this has one downside; the values are such that when the octave is divided into upper and lower halves based on bit 8, the the notes get divided unequally, 7 notes in low half and 5 notes in upper half. Usually this is not a problem.

If you want to use the other setting, where bit 9 defines the split point, and you want to divide the octave into 6 notes in low half and 6 notes in upper half, the values are:
365,387,410,435,460,488,517,547,580,615,651,690
And you still get highest possible FNUM values.

Of course there are other ways as well, this was just an example.

Reply 3 of 3, by buzzy

User metadata
Rank Newbie
Rank
Newbie

jwt27, many thanks for your prompt reply, that helped me enormously and this morning I have managed to get a recogniseable tune from what I am doing.

Jepael, I am at the first steps with this after a long time away from doing anything technical, but your explanation was also easy to understand and useful to read. I am sure I shall refer to it again later on.

What I am trying to do is to create a MIDI synth/sound module using an OPL chip, but it is first steps at the moment.

Than you both for such easy to read and understand explanations.

Buzzy