ECE 140 Lab #7

FM (Frequency Modulation) Synthesis

Introduction Frequency modulation is a computationally efficient way to create musical tones with complex and rapidly evolving spectra. In this project you will use Matlab to create a variety of musical sounds with FM with the goal of making as realistic an instrument sound as possible.

FM signals It is straightforward to create a basic FM waveform. The parameters that define the waveform are:

fc = carrier frequency fm = modulation frequency MI = modulation index A = amplitude

With these definitions a basic FM waveform can be represented as follows:

y = A*sin(2πfct + MI*sin(2πfmt))

One can make A and MI functions of time and achieve many interesting effects, some of them highly suggestive of actual musical instrument sounds!

Part I – The FM generator The furnished m-file fmgui.m provides a GUI (Graphical User Interface) driven FM synthesis application. You will need to download this m-file as well as a number of other supporting files: mbox.m, multbutton.m, multspecbutton.m, multspecsoundbutton.m. Make sure that these files are all in the Matlab path.

Part II - Generation of the tones of specific instruments You should save your best examples of each class of instrument to a file that you will hand in electronically. Each time you create a new sound file it is in the workspace variable ‘y’ and the sample rate is 44,100. So to play the sound file from the Matlab Command window type in the command, soundsc(y,44100). After you make a sound that you want to save, type the following in the Command window;

save fname variable where ‘fname’ is the name of the file the sound will be saved to and ‘variable’ is the workspace variable name, ‘y’ in the case of the fmgui program. Save your sound files with descriptive names and email them to the instructor or TA with your lab writeup.

Synthesizing Brasslike Horn Sounds: Set the modulating frequency equal to the carrier frequency for a harmonicity ratio, H = fm/fc = 1. The main characteristic that one must capture to make a brass-like tone is to make the bandwidth, determined by the modulation index, a strong function of the amplitude.

1 ECE 140 Lab #7

Experiment with various values for the minimum and maximum modulation index to see if you can get a sound that resembles that of a brass instrument.

Synthesizing a Sound: The bassoon and other double instruments are characterized by substantial spectral power in the higher harmonics and a weak fundamental. In addition to using a the bassoon, , English horn, and also have conical (tapered) bores like a Saxophone. The spectra of the sounds from conical bore instruments show harmonics at all multiples of the fundamental frequency. To simulate an instrument with all harmonics present, but with the strongest one not necessarily the fundamental, set the carrier frequency to a harmonic of the modulating frequency, such as the fifth. This would correspond to a harmonicity ratio of H = fm/fc = 1/5. Experiment with the value of H, try 1/4, 1/6 etc. to see if you can get a reasonable facsimile of a double-reed instrument tone. The modulation index probably does not have to be too great, nor does it have to vary over a large range in this case.

Synthesizing a Clarinet Sound: Cylindrical bore instruments with one open end and one closed end (like the clarinet) are characterized by spectra that contain mostly the odd number harmonics of the tone’s fundamental frequency. It is left to you to figure out how to choose the carrier and modulating frequencies to achieve this. Hint: consider what happens when the Harmonicity ratio is greater than unity. The attack may also contain a greater number of harmonics than the steady state tone so the modulation index may need to start off large and decrease with time.

Synthesizing Gongs and Cymbal Sounds: A gong-like tone may be synthesized by choosing an irrational number for the harmonicity ratio. Such sounds also start off loud and quickly decay in amplitude; furthermore the bandwidth of the tone often increases immediately after the attack (for a fraction of a second) and then decreases as the sound decays away. You should experiment with different values of the harmonicity ratio, modulation index and amplitude to make a sound like a gong or a bell.

Other Possibilities: You can extend the basic FM technique in a variety of ways, all of them easily programmable in Matlab. One option is to explore the sonic possibilities using multiple frequency modulation terms. You can create a sound to mimic an existing instrument or you can use your imagination to make a sound no one has heard before. For example you could create a signal with harmonics that are not integer multiples of the fundamental, such as a piano tone. The inharmonicity, In of the n’th overtone of a piano note, fn may be expressed as

#" ! !" = with !" = #" "#! where B is typically 1 cent near middle C. So, for example, the 2nd harmonic, n = 2, would be 4 cents sharp, the third harmonic would be 9 cents sharp, the 4th harmonic would be 16 cents sharp etc. (Remember that there are 100 cents in a semi-tone.)

To achieve this effect use a series of modulation terms, each one with a relatively small modulation index so that each term generates only one sideband, but each term should be chosen at a modulation frequency that will generate an inharmonically related upper partial.

2 ECE 140 Lab #7

Use this technique to make a sound like a piano tone and include any computations that you do in your write-up.

Also use the multiple modulation technique with modulating frequencies that aren't so close to each other. Try modulating frequencies that are in ratios of certain special numbers such as π, e, or the golden ratio, (1 + √5)/2. See if you can create any interesting sounds.

Finally, some far-out effects can be achieved by using a FM signal to modulate another FM signal. This could be represented by the following expressions. y(t) represents the first FM signal, which then modulates another carrier at fc2 to generate z(t). y(t) = sin(2πfc1t + MI1*sin(2πfm1t)) z(t) = sin(2πfc2t + MI2*y(t))

This method can create sounds almost like broadband noise or a metallic crash. Write a Matlab program to create such a double-modulated tone and try to find parameters that generate an interesting sound. Here is a start on the program.

R = 44100; % Sample Rate t = 0:1/R:3; % Generate a time vector 3 seconds long fc1 = 200; fm1 = 200; MI1 = 1; fc2 = 300; MI2 = 2; y = sin(2*pi*fc1*t + MI1*sin(2*pi*fm1*t)); z = sin(2*pi*fc2*t + MI2*y); soundsc(z,R)

Report: Save all of your generated sound files as wav files or compress them to MP3. The write-up for this lab should have a brief description of how you arrived at your various parameter choices, any calculations you made, etc., and it also should give the parameters for the sound files that you turn in.

3