[JPG image artwork that is a companion to the text]

FM Synthesis using Scilab


It would seem that fm synthesis kind-of came and went in the 1980's when the Yamaha company came out with their DX series of keyboard synthesizers. The Yamaha DX7 keyboard had some realistic-sounding patches (although synthesizers not longer use patch cords that interconnect oscillator modules, the word patch is now the common way to refer to a sound setting on the synthesizer).

By today's standards the fm sounds on the DX7 don't sound very real. The current top-line synthesizer by Yamaha, the ES6, has realistic patches that make the DX7 sound like a toy. To get an idea of what the ES6 can sound like, you might listen to an example composition I created entirely on the ES6. But in the early 1980's nothing so realistic as the DX7 had ever been heard. We were still in the days of synthesizers that sounded like radar beacons patched into a sound system. The Moog and the Arp were just then becoming digital. Some synthesizers were now producing some awesome (although not actually realistic) strings patches. On the Yes album called "Going For The One," which came out in 1977, Rick Wakeman was playing what the album credits described as a "Moog polyphonic synthesizer," with an awesome strings patch.

I first learned about fm synthesis from a one-time friend at the University of California, Davis. I was then a physics major at UCD. This friend told me about the DX7 and fm synthesis and invited me to his home to hear it. I was very impressed. He had a computer (very impressive back then!) connected by MIDI to his DX7. This was twenty years before I would get around to trying it.

I couldn't afford to buy a DX7, being a poor college student. I had to be happy fantasizing about the DX7. I sat in the univerity computer lab for hours printing out graphs of fm waveforms that I created on the computer, and I wished that I had a DX7 so that I could hear those waveforms. I researched how fm synthesis might be done with analog electronics. But everything I could find in the university library was about fm in radio signals. The subject of fm in the electrical engineering manuals dealt entirely with modulating a carrier wave with a signal whose frequency was below the carrier frequency. But fm synthesis in the DX7 was performed by modulating the carrier with a higher frequency than the carrier. I have still never seen a VCO (voltage controlled oscillator) circuit that will perform fm on its carrier signal.

In the summer of 1987, while waiting to be admitted to the physics graduate school at the University of California, San Diego, I worked out the mathematics of the fm frequency spectrum. For those of you who already have training in advance mathematics, look in your special functions reference at the section on generating functions for bessel's functions. The spectrum can be calculated analytically as a fourier series whose amplitudes are bessel's functions. It takes a lot of work to work out the frequency amplitudes, and that's just with two fm operators. If you try it with three operators the amount of calculation becomes to great. If you really want to see the spectrum of an fm signal you can do it easily with an FFT (fast-fourier transform) on your PC using Scilab. In practice, looking at this spectrum is not very helpful getting the sound you like.

frequency modulation

We saw on the first page, basic sound generation, a simple formula for fm synthesis.

Written as a Scilab command this is

ym = sin(x + sin(2*x));

This equation corresponds to a two-operator fm algorithm. The word operator was used by Yamaha for the algorithm diagrams that were displayed on the control panel of their keyboards. The equation would have been shown like the image below.

[JPG image artwork that is a companion to the text]

The first sine function corresponds to operator 1, and the second, embedded sine function corresponds to operator 2. Operator 2 is said to be modulating operator 1. In the equation above I left out a couple of details. The second operator can have its own frequency multipler and its amplitude changed. The equation should really be written as

ym = A1 * sin(f1*x + A2 * sin(f2*x))

The two-operator fm algorithm is not very powerful. It doesn't sound very much better than an analog synthesizer. This is the algorithm that was used for the onboard fm synth on the PC sound cards.

By contrast, the Yamaha DX7 keyboard has 6 operators. For example, algorithm 29 on the DX7 is displayed with the following picture.

[JPG image artwork that is a companion to the text]

The mathematics for this algorithm is written out like the following expression:

ym = A1 * sin(f1*x) +
A2 * sin(f2*x) +

A3 * sin(f3*x + A4 * sin(f4*x)) +

A5 * sin(f5*x + A6 * sin(f6*x +

A6 * sin(f6*x + A6 * sin(f6*x + ...))))

The last term, the term with A6, demands some explanation. You can see from the algorithm diagram that operator 6 modulates itself. So each term with with representing operator 6 must contain itself as a modulator, ad infinitum. I actually think that an operator modulating itself is the creation of digital synthesizer companies such as Yamaha. What it means for an oscillator to modulate itself (at frequencies higher than the carrier) is open to discussion. I'll tell you how it think it is accomplished digitally below.

The above equation, except for the infinite series, is in a form that can be produced using Scilab software. We saw on the previous page, How to Create a Wave File using Scilab, how to use Scilab commands. You can use the above equation, but replace

x = 2 * pi * (f / Fs) * N;

So what about the self-modulation of operator 6, the infinite sum? The answer is that you need to create the array for operator 6 separately by iterating its values a few times. You would first set up operator 6 with a sine wave array, like

op6 = A6 * sin(f6 * x);

The type the equation again, but this time with operator 6 modulating itself:

op6 = A6 * sin(f6 * x + op6);

Then do it again exactly as above (you can hit the up arrow key to retrieive the previous line), again and again:

op6 = A6 * sin(f6 * x + op6);
op6 = A6 * sin(f6 * x + op6);
op6 = A6 * sin(f6 * x + op6);
op6 = A6 * sin(f6 * x + op6);
op6 = A6 * sin(f6 * x + op6);

Now substitute the operator 6 array into the fm equation.

ym = A1 * sin(f1*x) + A2 * sin(f2*x) + A3 * sin(f3*x + A4 * sin(f4*x)) +
A5 * sin(f5*x + op6);

Now you can assign amplitude coefficients, A1, A2, A3, ..., and operator frequencies, f1, f2, f3, ..., to the equation in Scilab and create the sound file the same way we did on the earlier page, How to Create a Wave File using Scilab.

Music Synthesis and Physics Home
[JPG image artwork that is a companion to the text]
© Alfred Steffens Jr., 2007