FM Synthesis

An investigation into the behaviour of the Yamaha OPL3 chipset.
With a view to a more accurate emulator

Re: FM Synthesis

Postby carbon14 » Wed Jul 06, 2011 4:21 pm

Feedback was giving me trouble.

I was trying to study just the effect of feedback on the square waves. These as expected show a noise around the downslope, and a delay in the upslope. But what I wasn't expecting was that the noise had a period of three samples.

This really confused me. If the feedback was from the previous sample, there should be a 2 sample period to the noise. During the first half of the wave, the feedback is pushing you forward so you reach the downslope early. At this point, the output suddenly drops, so that feedback pushes you back into the high part of the waveform, and the next output goes up again.

If the feedback is delayed by two samples, then the noise should have a period of 4 samples.

However I think I have it cracked.

The feedback phase shift is a sum of the previous two samples, shifted by some amount directly related to the value of FB. This seems to give the correct result.
User avatar
carbon14
 
Posts: 124
Joined: Tue Aug 05, 2008 9:11 am
Location: York, England

Re: FM Synthesis

Postby opl3 » Wed Jul 06, 2011 7:46 pm

Wow, I have seen the exact same calculation for feedback in a OPL3 emulator before, so both you and the emulator must be correct.

I initially thought it would be simpler to have just one sample for feedback, either previous (N-1), or one before that (N-2), and I was a bit skeptical when I saw the emulator code.

However this most likely is done to make the feedback both more random or non-obvious (uses two samples instead of one) and/or more stable (flywheel effect). The sum of two previous samples is a simple low-pass FIR filter (with gain of 2 I guess), or thinking in another way, just a moving average (but without dividing the result by 2).

Nice work! Now it is interesting to see the dynamic behavior when the feedback value is changed on the fly, or toggled between on and off.
opl3
 
Posts: 55
Joined: Sun Sep 26, 2010 8:11 pm

Re: FM Synthesis

Postby carbon14 » Sat Jul 09, 2011 2:01 pm

Yes,

I was surprised by the result. I still need to go back and compare my model against the 30 or so samples I took from the real hardware, but it matches the few samples I've checked so far.

It would seem much simpler to use a single sample, but as I was coming to the conclusion that what I was seeing was a more gradual change of phase, I realised that it was almost a smoothing of the result. I think that this kind of low resolution filtering that you suggest is exactly the reason for it. All feedback systems of this type must eventually succumb to noise as you raise the feedback levels, I think this delays the onset somewhat. It's only by using the square waveforms with their sudden up and downslopes that you can really study this noisy area at low feedback depths and be sure of what contributions come from where.

As you say, there's no need for a separate divide by two in the averaging process. The fed-back value already needs to be shifted to accomodate the varying depths, the divide by two comes out in the wash at that point.
User avatar
carbon14
 
Posts: 124
Joined: Tue Aug 05, 2008 9:11 am
Location: York, England

Re: FM Synthesis

Postby carbon14 » Mon Aug 08, 2011 10:44 am

The feedback value is always modified by the FB register. Even though there are two previous samples to be combined to calculate the feedback, the same FB shift is always applied to both.

Hence it seems that these previous samples are stored in full, and then retrieved and shifted (using FB).

Rather than having been shifted and then stored.
User avatar
carbon14
 
Posts: 124
Joined: Tue Aug 05, 2008 9:11 am
Location: York, England

Re: FM Synthesis

Postby opl3 » Mon Aug 08, 2011 8:02 pm

carbon14 wrote:The feedback value is always modified by the FB register. Even though there are two previous samples to be combined to calculate the feedback, the same FB shift is always applied to both.

Hence it seems that these previous samples are stored in full, and then retrieved and shifted (using FB).

Rather than having been shifted and then stored.


So even if FB is 0, the samples are shifted through the delay registers (previous sample buffers), so that when FB is turned on or changed, there is always two previous values available?

In the MAME emulator, I think they only shift the output value through the previous sample buffers if FB is nonzero. So it means that when you turn feedback on while a sound is playing, the previous sample buffers contain just zero at first, instead of the real two previous outputs.

So based on your experiments, the two previous samples should always be available, and MAME emulator does this incorrectly then?
opl3
 
Posts: 55
Joined: Sun Sep 26, 2010 8:11 pm

Re: FM Synthesis

Postby carbon14 » Tue Aug 09, 2011 10:29 am

Yes that's correct.

Starting with an FB=0, when FB is set to 1 some 18 samples later, the phase offset is that expected from having both previous samples available.


I'm getting close to the stage where I can have a reliable model of those registers that I have already worked on. My intention soon is to wrap up the emulators from MAME and DOSBox so that I can carry out the same tests on the real chip, my model and the existing emulators to compare results.

I've tried hard not to study the specifics of the emulators prior to carrying out my experiments, to try to avoid clouding my judgements. I think that's been useful; I've already been badly wrong about several aspects of the chips behaviour, and experimental results have forced me to rethink my understanding.
User avatar
carbon14
 
Posts: 124
Joined: Tue Aug 05, 2008 9:11 am
Location: York, England

Previous

Return to Yamaha OPL-3 research

Who is online

Users browsing this forum: No registered users and 2 guests

cron