VOGONS


First post, by koko

User metadata
Rank Newbie
Rank
Newbie

Hey guys, new member, first post.

A little background:
I am attempting to wire up a YMF262 directly to an Arduino Nano along with a whole bunch of twisty nobs and switches to directly control each of the settings of the four operators and handle midi input to play music. I am using 6-voice Polyphony, so all channels receive the same operator settings.

The YMF262 has a register that enables backwards compatibility with OPL2. Once you enable OPL3 mode, you can modify a second bank of registers, get access to more wave forms, and enable 4-op channels.

When I initialize the chip I go through the following steps:
• Hard-reset the chip (taking the reset pin low then high)
• Turn on OPL3 mode (write bit 1 of register 0x05 on the second register bank)
• Clear out the second bank of registers (0x20…0xF5 = 0x00)
• Turn on 4-op mode for all 6 channels (set register 0x04 on bank two to 0x3F)

After that, I set all of the operator properties (A, D, S, R, WaveForm, Level, etc.) They are all controlled by the pots and switches.

At this point, I can play notes through midi and get sound, but there is some really odd behavior. Basically, Op 3 and 4 of each channel won’t produce sound.

I know that:
• I am in OPL3 mode - because I have access to all 8 waveforms
• All 6 4-op voices do produce sound (so I know that I am getting sound from both banks

The YMF262 supports a few different Synthesis Modes:
• Mode 0: Op1 x Op2 x Op3 x Op4
• Mode 1: (Op1 x Op2) + (Op 3 x Op4)
• Mode 2: Op1 + (Op2 x Op3 x Op4)
• Mode 3: Op1 + (Op2 x Op3) + Op4

When I flip through the modes:
• Mode 0 produces NO sound
• Mode 1 produces what sounds like a two-op sound (and indeed, I can only audibly tweak the properties of Op1 and Op2)
• Mode 2 produces sound only from Op1 (tweaking the properties of the other 3 operators doesn’t change anything)
• Mode 3 has the same results as mode 2

My hypothesis is that Op3 and Op4 are somehow muted. Because of the way the sounds are combined, this would produce the behavior above.

Here is where things get weird… If I turn off OPL3 mode (write 0 to bit 1 of register 0x05) after setting things up, all four operators (of channels 1-3) turn on and are combined as if in 4-OP OPL3 mode. Of course you can only use the first 3 channels (because channels 4-6 are in the second register bank which is locked), and you are limited to the four OPL2 waveforms. But this is the only way I have been able to get a 4-OP sound.

What is going on???

Reply 1 of 5, by Tiido

User metadata
Rank l33t
Rank
l33t

Are you using correct ops as 3 and 4 for a particular channel ? They are +8 registers away from op1 and 2 of a channel.
3x 4op channels in one set, 3x 4op channels in the second set, with 2 op channels 456 being ops3/4 for 4op channels 123, if that makes sense.

T-04YBSC, a new YMF71x based sound card & Official VOGONS thread about it
Newly made 4MB 60ns 30pin SIMMs ~
mida sa loed ? nagunii aru ei saa 😜

Reply 2 of 5, by koko

User metadata
Rank Newbie
Rank
Newbie

Thank you so much for the quick reply!

I think understand...

I am choosing the registers by adding an offset for the register set (e.g. $A0 for FNum low) to a channel offset to an operator offset. I put both offsets in arrays:

const short channelOffsets[6] = {0x0000, 0x0001, 0x0002, 0x0100, 0x0101, 0x0102 };
const short opOffsets[4] = {0x0000, 0x0003, 0x0008, 0x000B};

The third nibble selects the bank (1 = bank two)

So if I wanted the FNum (low) of operator 2, channel 4, the address would be:
0xA0 + 0x0100 + 0x0003 = 0x01A3

For properties that are only channel specific, I just add the channelOffset. So the $C0 register for channel 2 would be:
0x0001 + 0xC0 = 0x00C1

The really strange part is that when I switch back into OPL2 mode, Channels 1-3 remain in 4-OP mode, only this time all four of the operators seem to function. They are even being combined by the proper algorithm. I can independently change the properties of each operator, and the sound adjusts accordingly. But because it is OPL2 mode and the second bank of registers is locked, Channels 4-6 don't work, nor do the extended OPL3 waveforms.

Reply 3 of 5, by Tiido

User metadata
Rank l33t
Rank
l33t

That look correct, so I'm sort of out of ideas. Only thing i can think of making a difference is needing to set the LR bits of all the channels not just the 4op channels you use, but channels which ops in 2op more are using the ops that 4op channels are using.

The last tidbit is interesting, maybe the algo needs to be explicitly set to 2 op stuff ofter going back to OPL2 mode ...?

T-04YBSC, a new YMF71x based sound card & Official VOGONS thread about it
Newly made 4MB 60ns 30pin SIMMs ~
mida sa loed ? nagunii aru ei saa 😜

Reply 4 of 5, by koko

User metadata
Rank Newbie
Rank
Newbie

That was it! The L/R bits of both operator sets have to be enabled. THANK YOU! I rewrote my entire YMF262 library twice trying to figure that out. Of course it would be something so simple. 😀

Regarding the strange behavior, I believe that the ability to choose an output channel (they call so many things "channels") was a new feature in OPL3.

So if you:
• Turn on OPL3 mode
• Enable 4-OP mode for channels 1-3
• Only enable output channels for only OP1/2
• Then disable OPL3 mode

Then:
I suspect that the chip ignores the output channel bits—because they are not OPL2 compliant—thus turning on all four operators. BUT, the chip still supports the 4-OP algorithms (that were set in the second register bank) even though it is in compatibility mode. So it was kind of working—at least just for the channels (1-3) that are in the first register bank.

Thank you again for your help!