• Please review our updated Terms and Rules here

Waveforms and Frequency modulation

per

Veteran Member
Joined
Jan 21, 2008
Messages
3,052
Location
Western Norway
I've recently done some research on Frequency Modulation with sinewaves, in order to get the most out of my latest acquirement.

First of all, even though Yahaha called their chips for FM, it's in fact PM (phase modulation). The only difference is that with FM, the amplitude change of the modulator equals the frequency change of the carrier. With PM, the change in the momentary amplitude change of the modulator equals the frequency change of the carrier.

If you like maths, there are some equations that better explains this:
  • FM: da = df
  • PM: d(da/dt) = df
Therefore, for PM:
F(t)=i*sin(G(t)+a*sin(H(t)+...))
  • d = Delta
  • i = carrier amplitude
  • a = modulator amplitude
  • f = frequency
  • t = time
  • F(t) = final waveform
  • G(t) = carrier source
  • H(t) = modulator source
  • ... = repeat the pattern for every other modulator connected in series to the main modulator.
Anyways, I have been experimenting the trial-and-error way using a fomula quite similar to the one above. My goal was to make a squarewave using no more than one voice. This is when applications like "Graph" comes in handy.

(Note: visual images of the waveforms on the bottom of this post)

I entered the general formula into Graph, and started poking around. I knew that due to the nature of sinewaves, there were no posibility for me to get it perfect, but it should be possible to get somewhat close. I basically have 7 different variables; the amplitude for the 3 modulators, and the frequencies.

One thing I noticed was that it was quite easy (using only operator 1 and 2) to make something that looked quite similar to what I tried to achive, but with the only problem that any pseudo-linear parts of the waveform were full of minor noise. It seems like the closer it comes my goal, the more severial the noise becomes. The only way to eliminate the noise is to neutralize it out using the remaining operators. This is the tricky part since figuring this out is a very amplitude-sensetive task. You basically ajust the amplitude for operator 3 and 4 slightly untill the noise is enough reduced, but be carefull as even minimal ajustements may have quite unpredictable effects on the overall waveform.

In the end I got some nice waveforms (square/triangle). Of course, there are no sharp edges, so I guess it will sound like the target wavetypes after you run them through a low-pas filter. Here is the different settings for the waveforms:
Code:
 +------+
 v      |
-+->Op1-+->Op2->Op3->Op4->
only one operator:
sin(x) = Plain sinewave
  • op4 frequency multiplier = 1
  • op3 volume = 127
two operators:
sin(x+((127-37)/127)sin(2x)) = sine-ish squarewave, might have noticeable noise
  • op4 frequency multiplier = 1
  • op3 volume = 37
  • op3 frequency multiplier = 2
  • op2 total level = 127
sin(x+((127-81)/127)sin(x)) = very sine-ish sawtoothwave, might have noticeable noise
  • op4 frequency multiplier = 1
  • op3 volume = 81
  • op3 frequency multiplier = 1
  • op2 volume = 127
three operators:
sin(x+((127-1)/127)sin(2x+((127-52)/127)sin(2x))) = Not that sine-ish squarewave, minimal noise
  • op4 frequency multiplier = 1
  • op3 volume = 1
  • op3 frequency multiplier = 2
  • op2 volume = 52
  • op2 frequency multiplier = 2
  • op1 volume = 127
sin(x+((127-39)/127)sin(x+((127-91)/127)sin(x))) = sine-ish sawtoothwave, practically no noise at all
  • op4 frequency multiplier = 1
  • op3 volume = 39
  • op3 frequency multiplier = 1
  • op2 volume = 91
  • op2 frequency multiplier = 1
  • op1 volume = 127
all four operators:
sin(x+((127-0)/127)sin(2x+((127-39)/127)sin(2x+((127-91)/127)sin(2x)))) = The best squarewave I could get, it still got a bit of sine, but practically no noise at all
  • op4 frequency multiplier = 1
  • op3 volume = 0
  • op3 frequency multiplier = 2
  • op2 volume = 39
  • op2 frequency multiplier = 2
  • op1 volume = 91
  • op1 frequency multiplier = 2
  • op1 feedback = 127
sin(x+((127-8)/127)sin(x+((127-59)/127)sin(x+((127-95)/127)sin(x)))) = better sawtoothwave, may contain minimal noise
  • op4 frequency multiplier = 1
  • op3 volume = 8
  • op3 frequency multiplier = 1
  • op2 volume = 59
  • op2 frequency multiplier = 1
  • op1 volume = 95
  • op1 frequency multiplier = 1
  • op1 feedback = 0
 

Attachments

  • PMsawtooth.jpg
    PMsawtooth.jpg
    83.7 KB · Views: 1
  • PMsquare.jpg
    PMsquare.jpg
    82 KB · Views: 1
Last edited:
Hi
Did you get a chance to put this through a sound board to see
how well it actually tracked?
Dwight

No, but I will be able to most problably within one week from now.

By the way, the volume settings are to be used with the YM2151, YM2164, YM2414, or any other PM synth using sinewaves where the maximum volume per operator is 127.

The nice thing with FM is that you can do all sorts of weird stuff to the waveform, as long as you don't want sharp edges on it (physically; the momentum of the speaker makes it unable to 100% correctly reproduce the sharp edges anyways).
 
By the way, the volume settings are to be used with the YM2151, YM2164, YM2414, or any other PM synth using sinewaves where the maximum volume per operator is 127.

Woops, turns out it's the other way around. The maximum is 0, and the minimum is 127. I have now corrected the volume settings.
 
Hi per,
I see you have taken the red pill for FM synthesis. Hold on tight, the rabbit hole is deep...

First off, what is your new acquirement? MSX Computer? DX series Synth? All fun toys.

Now, regarding FM vs. PM: they are the same thing, esp. if your dealing with sinusoidal modulators and carriers: after all the derivative of a sinusoid is a sinusoid. You might find the the math a bit easier if you use a complex decomposition, or even single-sided modulators (e^(i 2 pi t)). No matter what though you'll have to deal with Bessel functions eventually.

Grab a book on communications theory, those tend to explain it better than synth theory books, though there's a couple of good ones I can think of. Also check out CSound and Supercollider.
 
Hi per,
I see you have taken the red pill for FM synthesis. Hold on tight, the rabbit hole is deep...

First off, what is your new acquirement? MSX Computer? DX series Synth? All fun toys.

Now, regarding FM vs. PM: they are the same thing, esp. if your dealing with sinusoidal modulators and carriers: after all the derivative of a sinusoid is a sinusoid. You might find the the math a bit easier if you use a complex decomposition, or even single-sided modulators (e^(i 2 pi t)). No matter what though you'll have to deal with Bessel functions eventually.

Grab a book on communications theory, those tend to explain it better than synth theory books, though there's a couple of good ones I can think of. Also check out CSound and Supercollider.
It's just a IBM Music feature card; in other word a Yamaha FB-01 on-an-ISA-card. I heard it is capable of producing quite good bass, organ, and metallic sound.

By the way, the derivative of sin(x) is not exactly a sin function but a cosin function. of course you can see it as a sine wave with an offset of a half wavelength (you problably know this already). I'm unsure if you can change the offset of the waves with the synth I have gotten.

I guess the amplitude values I had to use trial-and-error to find could be found easily using, as you say, Bessel functions. However, I guess I should wait to investigate that untill I got some time to spare.
 
It's just a IBM Music feature card; in other word a Yamaha FB-01 on-an-ISA-card. I heard it is capable of producing quite good bass, organ, and metallic sound.

By the way, the derivative of sin(x) is not exactly a sin function but a cosin function. of course you can see it as a sine wave with an offset of a half wavelength (you problably know this already). I'm unsure if you can change the offset of the waves with the synth I have gotten.

I guess the amplitude values I had to use trial-and-error to find could be found easily using, as you say, Bessel functions. However, I guess I should wait to investigate that untill I got some time to spare.

(Argh! I typed a long reply and then accidentally closed the window! Trying again...)

Ah, I still have an FB-01. Don't use it much, always considered it a bit limited, but then again, I was spoiled from having a DX7IIFD - now THERE was a sweet machine!

Anyways, regarding FM/PM: yes, note that I carefully used "sinusoid" rather than sin - sinusoid is any function of the type e^(ix) with x a linear function. For me, cos(x) is simply the real component thereof and sin(x) the imaginary: e^(ix) = cos(x) + i sin(x) (Thank you Mr. Euler!) Note you can derive almost all of trigonometry from that, much easier than messing about with sin and cos.

It is interesting that the "Phase" terminology was used by competitors to Yamaha to get around the FM patents: Casio had "Phase Distortion" in their CZ line of synths, Korg called it "Variable Phase Synthesis" and Roland had "Linear Arithmetic" - but it was all basically FM.

Perceptually however, phase offsets actually don't matter so much in FM synthesis, especially if the frequencies of the operators are not simple ratios of each other. Even though the waveforms look very different, the harmonic components will have similar amplitude. How much the harmonic phase differences are audible has been a debate for well over 60 years.

The best paper to read is probably the one by Mr. FM himself, John M. Chowning: You can find it at this site (not mine):
The Synthesis of Complex Audio Spectra by Means of Frequency Modulation
Also http://yala.freeservers.com/2fmsynth.htm

Remember you can NEVER get a perfect sounding square wave of arbitrary frequency out of a digital system, only ones with frequencies that are factors of your sampling rate. Otherwise, you'll get aliasing. So, generating a square wave with FM is an exercise of getting it "close enough"...

Try playing with MAX/MSP. Expensive, but has a 90-day trial period. (After that you can switch to the free Pure Data, but MAX/MSP is easier to learn due to the inline help system)
 
(Argh! I typed a long reply and then accidentally closed the window! Trying again...)

Ah, I still have an FB-01. Don't use it much, always considered it a bit limited, but then again, I was spoiled from having a DX7IIFD - now THERE was a sweet machine!

Anyways, regarding FM/PM: yes, note that I carefully used "sinusoid" rather than sin - sinusoid is any function of the type e^(ix) with x a linear function. For me, cos(x) is simply the real component thereof and sin(x) the imaginary: e^(ix) = cos(x) + i sin(x) (Thank you Mr. Euler!) Note you can derive almost all of trigonometry from that, much easier than messing about with sin and cos.

It is interesting that the "Phase" terminology was used by competitors to Yamaha to get around the FM patents: Casio had "Phase Distortion" in their CZ line of synths, Korg called it "Variable Phase Synthesis" and Roland had "Linear Arithmetic" - but it was all basically FM.

Perceptually however, phase offsets actually don't matter so much in FM synthesis, especially if the frequencies of the operators are not simple ratios of each other. Even though the waveforms look very different, the harmonic components will have similar amplitude. How much the harmonic phase differences are audible has been a debate for well over 60 years.

The best paper to read is probably the one by Mr. FM himself, John M. Chowning: You can find it at this site (not mine):
The Synthesis of Complex Audio Spectra by Means of Frequency Modulation
Also http://yala.freeservers.com/2fmsynth.htm

Remember you can NEVER get a perfect sounding square wave of arbitrary frequency out of a digital system, only ones with frequencies that are factors of your sampling rate. Otherwise, you'll get aliasing. So, generating a square wave with FM is an exercise of getting it "close enough"...

Try playing with MAX/MSP. Expensive, but has a 90-day trial period. (After that you can switch to the free Pure Data, but MAX/MSP is easier to learn due to the inline help system)

Thanks for the info. Even though the FB-01 is limited in comparasion to thew DX7II, it's the best hardware-synth I can get for the PC that is based on traditional synthezisis (the Roland LAPC-1 is sample-based with subtractive synthezisis plus reverb if I remember correctly. Perhaps it has some operators that uses fixed waveforms, but I don't know about any at this time).

The reason I went for this sync is because it's the only PC/XT/AT souncard by IBM, and I am an IBM PC collector. Those IBM music feature cards are quite rare and hard to come by, and it just happened to be one for sale on ebay a week ago. The fact that I research it's usage is just a side effect, since I like to have good understanding about how things work.

Rigth now I am experimenting in using envelopes and two modulators in series (overtones of carrier), parralel to the last modulator (carrier waveform controller) in order to obtain a "minimoog"-style filter effect.
 
Last edited:
Care to explain this statement further?

Easy, mea culpa, I was mistaken. :)

I looked it up again, and while it's from the same time period, LA is probably more a type of Wavetable Synthesis, not FM/PM (although ISTR, PWM featuring heavily which has some similarity if used at the correct frequencies).

Sorry for the confusion.

(edit: Waveform -> Wavetable)
And I still have a RAP-10 kicking around here somewhere...
 
Last edited:
Rigth now I am experimenting in using envelopes and two modulators in series (overtones of modulator), parralel to the last modulator (carrier waveform controller) in order to obtain a "minimoog"-style filter effect.

My favorite trick was always to toss in a final modulator at the bottom with a very low fixed frequency (1-5Hz) for a sweet analog-ish phaser/flange (?) effect.
Kinda hard to do with only 4 operators though.
 
My favorite trick was always to toss in a final modulator at the bottom with a very low fixed frequency (1-5Hz) for a sweet analog-ish phaser/flange (?) effect.
Kinda hard to do with only 4 operators though.
Too bad the LFO that only affects the carrier outputs. The normal operators can only do frequencies from C-2 through G8 anyways (where middle C is C3).

Isn't it possible to get all functions you can ever dream about if you use an actual module-based traditional "plug-and-play" (the literary sense, not PnP) synthsizer, at the same time as you got a wide selection of modules (talking about dozeens of modules)? The downside then is that I need an entire room to fit it, enough electricity to power half a city, and it will problably end up looking like a mess spagetti after use. Of course I am exaggerating a bit, but if it actually was the case; there would have been about no limits on what kind of sound you could produce. Too bad they cost too much for me to buy one.
 
Last edited:
Too bad the LFO that only affects the carrier outputs. The normal operators can only do frequencies from C-2 through G8 anyways (where middle C is C3).

Oh? That must be a limitation of the 4-Op synth chip. The "big" 6-op synths (DX7 etc) can set the frequency of an operator to a fixed value specified in Hz. Can serve for very freaky effects.

Isn't it possible to get all functions you can ever dream about if you use an actual module-based traditional "plug-and-play" (the literary sense, not PnP) synthsizer, at the same time as you got a wide selection of modules (talking about dozeens of modules)? The downside then is that I need an entire room to fit it, enough electricity to power half a city, and it will problably end up looking like a mess spagetti after use. Of course I am exaggerating a bit, but if it actually was the case; there would have been about no limits on what kind of sound you could produce. Too bad they cost too much for me to buy one.

The major problem for synths is, and always has been controllability. Creating "any" sound is easy: Imagine a room with say, 16000 potentiometers. You now attach a wire to each of them, and for 1/16000th second, the voltage at the speaker takes on the value of a pot, then the next is selected. With this setup, you can create _any_ sound one second long as long as no component of that sound is of a frequency larger than 8000 Hz.

This is in fact how sampling works.

But musically, this is (almost) useless: you have no way of modifying the sound in any way that is intuitive (disregard the possibility of changing the timing here!). Musicians want to change parameters such as volume, pitch, and timbre. You want to have a palette of sounds, where the listeners brain can follow a pattern - various pitch and amplitude with the same timbre; in rare cases composers play with varying timbre with the same pitch (Listen to Ravel's "Bolero"!) (This goes into a field called "Auditory Scene Analysis", look up Albert Bregman's book)

So, a musician wants an instrument where the sound can be controlled in a (somewhat) predictable way: turn a knob here, the volume changes; touch a key further over there, the pitch changes; turn a knob there, the vibrato gets stronger.

We engineers just want to put knobs and buttons everywhere. Makes it fun! :D
 
Back
Top