OPLL frequency calculation & pitch bend - BLARGH!?

Página 1/2
| 2

Por commodorejohn

Expert (92)

Imagen del commodorejohn

20-01-2011, 05:46

Oh, Yamaha, why must you be so impenetrable? I've been hacking up some sound-test software and poring over tech documents with an eye towards writing a music engine that supports the OPLL chip found in MSX-Music cartridges and MSX-2+ machines, and chief among the things that baffle me about the chip (just after why maximum volume is 0) is the crazy moon logic that drives the frequency-control registers.

It took me the better part of the afternoon to even wrap my head around how it works, but it's my understanding that, given the 9-bit "F-number" and the 3-bit "block," the formula is:

Frequency = Fnum * (2 ^ Block-1) * 50000 / 2^18

where 50000 is the master frequency for the chip. The crazy thing is, and this took me hours of wracking my brain and actual direct confirmation on my own unit to understand, even though the block value would logically serve as an octave-selector, the ranges overlap! Block value 1 gives the various F-numbers output frequencies from about 0.19Hz to 97Hz, block 2 covers from 0.38Hz to 194.93Hz, and so on and so forth.

This means that, even though there's exactly as much register space devoted to frequency control as on the PSG or SCC, the huge majority of the range is completely redundant. I'm wondering if I shouldn't just hard-code the block value to 7, since that gives a range from ~12Hz to ~6KHz, more than covering the full piano keyboard. I'm just not 100% sure on this, since it means that a range of frequencies with over 4000 values on the PSG/SCC is going to be squashed to under 512 on the OPLL!

If I wanted to make use of all the bits, it'd be a simple thing to work out a pre-calculated note table with the optimum block/fnum combination for each note (and, in fact, I already did.) But the question then is, how do I handle pitch bends? They're not too difficult to figure out in a linear frequency range, but when you bring the block numbers into it, it's madness.

Does anyone have any thoughts on this or experience with coding for Yamaha FM chips? I keep thinking that there has to be something I missed, but I can't seem to find anything that would make this make any kind of sense at all...

Login sesión o register para postear comentarios

Por DamageX

Master (217)

Imagen del DamageX

20-01-2011, 09:43

I`m a little bit familiar with the YM2612. It uses the same scheme for specifying frequencies except with 11 bits for f-number. Looking at a couple of register dumps, I can tell you that the way Sega did it was by always using an f-number in the 600-1200 range, and setting the octave as needed to keep it there.

Por commodorejohn

Expert (92)

Imagen del commodorejohn

20-01-2011, 14:39

Yai. I suppose that might work, but it'd make pitch bends hell...

Por Manuel

Ascended (19469)

Imagen del Manuel

20-01-2011, 19:11

I use this expression to calculate the frequency of values in OPLL registers in an openMSX script:


"MSX-MUSIC" {
                        set regs "\"${soundchip} regs\""
                        set basefreq [expr 3579545.454545 / 72.0]
                        set factor [expr $basefreq / (1 << 18)]
                        if {$channel >= 9} {
                                #drums
                                incr channel -3
                        }
                        return "expr { (\[debug read $regs [expr $channel + 0x10]\] + 256 * ((\[debug read $regs [expr $channel + 0x20]\]) & 1)) * $factor * (1 << (((\[debug read $regs [expr $channel + 0x20]\]) & 15) >> 1)) }"

Does that help, or is it gibberish?

Por commodorejohn

Expert (92)

Imagen del commodorejohn

20-01-2011, 19:14

I understand that, it's just the whole "trying to figure out how to build a music engine for this" thing that baffles me.

Por NYYRIKKI

Enlighted (6067)

Imagen del NYYRIKKI

20-01-2011, 20:02

Maybe you should try to check out how MoonBlaster does this:
http://www.msx.org/forumtopic9883p23.html

Por WORP3

Paladin (864)

Imagen del WORP3

20-01-2011, 20:37

Please don't use the value's that you will find in the yamaha datasheets as they are pre calculated for a frequency of 3.6 Mhz not the msx frequency of 3.54 Mhz !
You don't want to know what i all came across during the MIDI-PAC development, sjjeesss some really won't take the effort to read the datasheet Sad

But for your question, use this formula to calculate the correct frequency for a specific keyboard note (Note 69 will give you a A on octave 4):

fmus=440*(2^(((<note>-69)/12)))

Then use this formula to calculate the F-Num for a specific octave (default 4):
Fnum=(<frequency>*5,27284)/(2^(<Octave>-1))

Just calculate the desired frequency's for one octave as you use the mul bit's for the octave !

But if you want to calculate your pitch bending destination, use this magic number: 1,059463
It's the note to note multiplier value, try it !

Good luck,
Tjeerd.

Por commodorejohn

Expert (92)

Imagen del commodorejohn

20-01-2011, 20:45

Yeah, I figured that would be the case, so I put in an option in my table-builder to change the master clock frequency.

Por ro

Scribe (4964)

Imagen del ro

21-01-2011, 09:56

Perhaps MSD can shed some more light on the subject? (he's been doin' calcs on OPLL frq a while ago..) where ye at Marcel!?

Por Manuel

Ascended (19469)

Imagen del Manuel

21-01-2011, 18:01

WORP3: um, MSX clock runs at 3579545.454545 Hz... not 3.54MHz... or did I misunderstand you?

Por WORP3

Paladin (864)

Imagen del WORP3

21-01-2011, 18:33

@Manuel, you are correct that 3.54 was a typo Sad
Formula is still right as the pre-calculated did originate from a 3.57.. MHz base.

Página 1/2
| 2