DSP First Lab 05: FM Synthesis for Musial Instruments - Bells and Clarinets Pre-Lab and Warm-Up: You should read at least the Pre-Lab and Warm-up setions of this lab assignment and go over all exerises in the Pre-Lab setion before going to your assigned lab session. Verifiation: The Warm-up setion of eah lab must be ompleted during your assigned Lab time and the steps marked Instrutor Verifiation must also be signed off during the lab time. One of the laboratory instrutors must verify the appropriate steps by signing on the Instrutor Verifiation line. When you have ompleted a step that requires verifiation, simply demonstrate the step to the TA or instrutor. Turn in the ompleted verifiation sheet to your TA when you leave the lab. Lab Report: It is only neessary to turn in a report on Setion 4 with graphs and explanations. You are asked to label the axes of your plots and inlude a title for every plot. In order to keep trak of plots, inlude your plot inlined within your report. If you are unsure about what is expeted, ask the TA who will grade your report. 1 Introdution The objetive of this lab is to introdue more ompliated signals that are related to the basi sinusoid. These signals, whih implement frequeny modulation (FM) and amplitude modulation (AM), are widely used in ommuniation systems suh as radio and television), but they also an be used to reate interesting sounds that mimi musial instruments. There are demonstrations on the CD-ROM that provide examples of these signals for many different onditions. 2 Overview Frequeny modulation (FM) an be used to make interesting sounds that mimi musial instruments, suh as bells, woodwinds, drums, et. The goal in this lab is to implement one or two of these FM shemes and hear the results. We have already seen that FM defines the signal x(t) as a osine with time-varying angle x( t) = Aos( ϕ( t)) and that the instantaneous frequeny hanges aording to the derivative of φ(t). If φ(t) is linearly inreasing with time x(t), is a onstant-frequeny sinusoid; whereas, if φ(t) is quadrati in time, x(t) is a hirp signal whose frequeny hanges linearly in time. FM musi synthesis uses a more interesting φ(t) one that is sinusoidal. Sine the derivative of a sinusoidal φ(t) is also sinusoidal, the instantaneous frequeny of x(t) will osillate. This is useful for synthesizing instrument sounds beause the proper hoie of the modulating frequenies will produe a fundamental frequeny and several overtones, as many instruments do. The general equation for an FM sound synthesizer is
x t) = A( t)os( π f t + I ( t) os(2πf t + φ ) + φ ) (1) ( m n where A(t) is the signal s amplitude. It is a funtion of time so that the instrument sound an be made to fade out slowly or ut off quikly. Suh a funtion is alled an envelope. The onstant parameter f is alled the arrier frequeny. Note that when you take the derivative of φ(t) to find the instantaneous frequeny f i (t), the result is f i 1 d ( t) = ϕ( t) 2π dt = 1 2π d dt (2πf t + I( t)os(2πf t + φ ) + φ ) m = f di I( t) f m sin(2π f mt + φm ) + os(2πf m + φm ) dt Note that f is a onstant in (2). It is the frequeny that would be produed without any frequeny modulation. The parameter f m is alled the modulating frequeny. It expresses the rate of osillation of f i (t). The parameters φm and φ are arbitrary phase onstants, usually both set to -π /2 so that x(0) = 0. 1 The funtion I(t) has a less obvious purpose than the other FM parameters in (1). It is tehnially alled the modulation index envelope. To see what it does, examine the expression for the instantaneous frequeny (2). The quantity I(t) f m multiplies a sinusoidal variation of the dl frequeny. If I (t) is onstant or is relatively small, then I(t) f m gives the maximum amount dt by whih the instantaneous frequeny deviates from f. Beyond that, however, it is diffiult to relate I (t) to the sound made by x(t) without some rather advaned mathematial analysis. In our study of signals, we would like to haraterize x(t) as the sum of several onstantfrequeny sinusoids instead of a single signal whose frequeny hanges. In this regard, the following are fats that an be demonstrated experimentally: when I (t) is small (e.g., I 1), low multiples of the arrier frequeny (f ) have high amplitudes. When I(t) is large (I > 4), both low and high multiples of the arrier frequeny have high amplitudes. The net result is that I (t) an be used to vary the harmoni ontent of the instrument sound (alled overtones). When I (t) is small, mainly low frequenies will be produed. When I (t) is large, higher harmoni frequenies an also be produed. Sine I(t) is a funtion of time, the harmoni ontent will hange with time. For more details see the paper by Chowning 1. 1 Ref: John M. Chowning, The Synthesis of Complex Audio Spetra by means of Frequeny Modulation, Journal of the Audio Engineering Soiety, vol. 21, no. 7, Sept. 1973, pp. 526 534.
3.1 Chirps and Aliasing Use your hirp generation funtion from Lab 3 to synthesize a hirp signal with the following parameters: 1. A total time duration of 2.5 seonds where the desired instantaneous frequeny starts at 13,000 Hz and ends at 200 Hz. 2. Use a sampling rate of fs = 8000 Hz. Listen to the signal. What omments an you make regarding the sound of the hirp (e.g., is it linear)? Does it hirp down, or hirp up, or both? Create a spetrogram of your hirp signal. Use the sampling theorem (from Chapter 4 in the text) to help explain what you hear and see. In addition, make some theoretial alulations by hand: Determine the range of frequenies (in hertz) that will be synthesized by this VI. Make a sketh by hand of the instantaneous frequeny versus time. Explain how aliasing affets the instantaneous frequeny that is atually heard. Listen to the signal again to verify that it has the expeted frequeny ontent. Instrutor Verifiation (separate page) 3.2 Wideband FM Using a sampling rate of f s = 8000 Hz, generate a set of wideband FM hirps with sinusoidal modulation aording to the formula os 2 2 ) evaluated over the time interval 0 t 1.35 ses. (a) First of all, do the ase where f 0 = 900 Hz, f m = 3 Hz and B = 200. Generate the signal, plot its spetrogram and listen to the signal to see if it orresponds to the spetrogram. (b) Make a sketh (by hand) of the instantaneous frequeny for the signal in part (a). Instrutor Verifiation (separate page) () Now, hange fm to be fm = 30 Hz and B = 20, but keep f0 = 900 Hz. Generate the signal, plot its spetrogram and listen to the signal. (d) One again, sketh (by hand) the instantaneous frequeny for the signal in part () to see if it orresponds to the spetrogram. (e) Now, hange fm to be fm = 300 Hz and B = 2, but keep f0 = 900 Hz. Generate the signal, plot its spetrogram and listen to the signal. This is a ase of wideband FM, and the instantaneous frequeny onept no longer explains the sound we hear, but you should write a reasonable explanation for the spetrum that you observe.
Instrutor Verifiation (separate page) When unsure about a ommand, use help. 4 FM Synthesis of Instrument Sounds 4.1 Generating the Bell Envelopes Now we take the general FM synthesis formula (1) and speialize for the ase of a bell sound. The amplitude envelope A(t) and the modulation index envelope for the bell are both deaying exponentials. That is, they both have the following form: t τ y( t) = e (3) where τ is a parameter that ontrols the deay rate of the exponential. Notie that y(0) = 1 and y(τ) = 1/e, so τ is the time it takes a signal of the form (3) to deay to 1/e = 36.8% of its initial value. For this reason, the parameter τ is alled the time onstant. Use (3) to write a LabVIEW VI bellenv.vi that will generate a deaying exponential to be used later in synthesizing a bell sound. Use this basi arhiteture to build your VI. Beause this VI will be used in later labs, be sure to wire the onnetor pane to reate a sub VI like you learned in Lab 2. The funtion will be only one or two lines inside the MathSript node. The first line should define your time vetor based on fsamp and dur, and the seond generates the exponential (3). The bell s amplitude envelope, A(t), and modulation index envelope, I(t) are idential, up to a sale fator. τ () A e t A t = 0 and Hene, one all to the VI will generate the shape for both envelopes. I τ () t I e t = 0
4.2 Parameters for the Bell Now that we have the bell s amplitude and modulation index envelopes, we an reate the atual sound signal for the bell by speifying all the parameters in the general FM synthesis formula (1). The frequenies f and f must be given numerial values. The ratio of arrier to m modulating frequeny is important in reating the sound of a speifi instrument. For the bell, a good hoie for this ratio is 1:2, e.g., f = 110 Hz and f m = 220 Hz. Now write a simple VI bell.vi that implements (1) to synthesize a bell sound. Your funtion A t τ should all bellenv.vi to generate () input to the following arhiteture to reate the desired VI. t t τ = A 0 e and I() t I e = 0. You will have to add this 4.3 The Bell Sound Test your bell VI using the parameters of ase #1 in the table. Play it with the sounds.vi at 11,025 Hz. 2 Does it sound like a bell? The value of I 0 = 10 for saling the modulation index envelope is known to give a distintive sound. Later on, you an experiment with other values to get a variety of bells. CASE f (Hz) fm (Hz) I0 τ (se) Tdur (se) fs (Hz) 1 110 220 10 2 6 11,025 2 220 440 5 2 6 11,025 3 110 220 10 12 3 11,025 4 110 220 10 0.3 3 11,025 5 250 350 5 2 5 11,025 6 250 350 3 1 5 11,025 The frequeny spetrum of the bell sound is very ompliated, but it does onsist of spetral lines, whih an be seen with a spetrogram. Among these frequenies, one spetral line will dominate what we hear. We would all this the note frequeny of the bell. It is tempting to guess that the note frequeny will be equal to f, but you will have to experiment to find the true 2 A higher sampling rate of 11,025 Hz is used beause the signal ontains many harmonis, some of whih might alias if a lower fs were used. You should experiment with lower values of fs to see if you an hear a differene, e.g., fs = 8000 Hz.
answer. It might be f m, or it might be something else perhaps the fundamental frequeny whih is the greatest ommon divisor of f and f m. For eah ase in the table, do the following: (a) Listen to the sound by playing it with sounds.vi. (b) Calulate the fundamental frequeny of the note being played. Explain how you an verify by listening that you have the orret fundamental frequeny. () Desribe how you an hear the frequeny ontent hanging aording to I (t). Plot f(t) versus t for omparison. (d) Display a spetrogram of the signal. Desribe how the frequeny ontent hanges, and how that hange is related to I (t). Point out the harmoni struture of the spetrogram, and alulate the fundamental frequeny, f 0. (e) Plot the entire signal and ompare it to the envelope A(t) generated by bellenv.vi. (f) Plot about 100 200 samples from the middle of the signal and explain what you see, espeially the frequeny variation. If you are making a lab report, do the plots for two ases hoose one of the first four and one of the last two. Write up an explanation only for the two that you hoose. 4.4 Comments about the Bell Cases #3 and #4 are extremes for hoosing the deay rate τ. In ase #3, the waveform does not deay very muh over the ourse of three seonds and sounds a little like a sum of harmonially related sinusoids. With a faster deay rate, as in ase #4, we get a perussionlike sound. Modifying the fundamental frequeny f 0 (determined in part (d) above) should have a notieable effet on the tone you hear. Try some different values for f 0 by hanging f and f m, but still in the ratio of 1:2. Desribe what you hear. Finally, experiment with different arrier to modulation frequeny ratios. For example, in his paper, Chowning uses a fundamental frequeny of f 0 = 40 Hz and a arrier to modulation frequeny ratio of 5:7. Try this and a few other values. Whih parameters sound best to you? 5 Optional: C Major Sale Finally, synthesize other note frequenies. For example, try to make the C-major sale (defined in Lab 3) onsisting of seven onseutive notes.
Lab 05 INSTRUCTOR VERIFICATION PAGE For eah verifiation, be prepared to explain your answer and respond to other related questions that the lab TA s or professors might ask. Turn this page in at the end of your lab period. Name: Date of Lab: Part 3.1 Aliasing of the linear FM Chirp: Verified: Date/Time: Part 3.2(a),(b) Sinusoidal FM Signal Generation: Verified: Date/Time: Part 3.2(e) Explain why the Wideband FM Spetrogram has the harateristis that you observe. Does the spetrogram math your hearing experiene when you listen to the sound in part (e)? Compare your observations to the spetrogram of other signals that you have seen in the leture or in the lab. Write a short explanation in the spae below: Verified: Date/Time:
6 Woodwinds As an alternative to the bell sounds, this setion shows how different parameters in the same FM synthesis formula (1) will yield a larinet sound, or other woodwinds. 6.1 Generating the Envelopes for Woodwinds There is a funtion on the CD-ROM alled woodwenv whih produes the funtions needed to reate both the A(t) and I (t) envelopes for a larinet sound. The file header looks like this: funtion [y1, y2] = woodwenv(att, sus, rel, fsamp) %WOODWENV produe normalized amplitude and modulation index % funtions for woodwinds % % usage: [y1, y2] = woodwenv(att, sus, rel, fsamp); % % where att = attak TIME % sus = sustain TIME % rel = release TIME % fsamp = sampling frequeny (Hz) % returns: % y1 = (NORMALIZED) amplitude envelope % y2 = (NORMALIZED) modulation index envelope % % NOTE: attak is exponential, sustain is onstant, % release is exponential The outputs from woodwenv are normalized so that the minimum value is zero and the max is one. Try the following statements to see what the funtion produes: fsamp = 8000; Ts = 1/fsamp; tt = delta : Ts : 0.5; [y1, y2] = woodwenv(0.1, 0.35, 0.05, fsamp); subplot(2,1,1), plot(tt,y1), grid on subplot(2,1,2), plot(tt,y2), grid on 6.2 Saling the Clarinet Envelopes Sine the woodwind envelopes produed by woodwenv range from 0 to 1, some saling is neessary to make them useful in the FM synthesis equation (1). In this setion, we onsider the general proess of linear re-saling. If we start with a normalized signal ynorm(t) and want to produe a new signal whose max is ymax and whose min is ymin, then we must map 1 to ymax and 0 to ymin. Consider the linear mapping: ynew(t) = _ ynorm(t) + _ (4)
Determine the relationship between _ and _ and ymax and ymin, so that the max and the min of ynew(t) are orret. Test this idea in MATLAB by doing the following example (where _ = 5 and _ = 3): ynorm = 0.5 + 0.5*sin( pi*[0:0.01:1]); subplot(2,1,1), plot(ynorm) alpha = 5; beta = 3; ynew = alpha*ynorm + beta; %<------ Linear re-saling subplot(2,1,1), plot(ynew) max(ynorm), min(ynorm) %<--- ECHO the values max(ynew), min(ynew) What happens if we make _ negative? Write a short one-line funtion that implements (4) above. Your funtion should have the following form: funtion y = sale(data, alpha, beta). What happens if we make _ negative? Write a short one-line funtion that implements (4) above. Your funtion should have the following form: funtion y = sale(data, alpha, beta). 6.3 Clarinet Envelopes For the larinet sound, the amplitude A(t) needs no saling the MATLAB funtion sound will automatially sale to the maximum range of the D/A onverter. Thus, A(t) equals the vetor y1. From the plot of y1 shown in Fig. 1, it should be obvious that this envelope will ause the sound to rise quikly to a ertain volume, sustain that volume, and then quikly turn off. Figure 1: Envelopes for the woodwinds. The funtions A(t) and are produed by saling y1 and y2, the outputs of woodwenv.
The modulation index envelope,, however, does not equal y2. The range for lies between 2 and 4 as in Fig. 1. Furthermore, there is an inversion so that when y2 is zero, should equal 4, and when y2 is one, should be 2. Using this information solve for the appropriate α and β then use sale to produe the modulation index envelope funtion (I) for a larinet sound. 6.4 Parameters for the Clarinet So far we have a general equation for FM signals, an amplitude envelope for the larinet, and a modulation index envelope for the larinet. To reate the atual sound signal for the larinet, we need to speify the additional parameters in (1). The ratio of arrier to modulating frequeny is important in reating the sound of a speifi instrument. For the larinet, this ratio should be 2:3. The atual note frequeny will be the greatest ommon divisor of the arrier and modulating frequenies. For example, when we hoose f = 600 Hz and fm = 900 Hz, the synthesized signal will have a fundamental frequeny of f0 = 300 Hz. Write a simple M-file larinet.m that implements the FM synthesis equation (1) to synthesize a larinet note. Your funtion should generate the envelopes A(t) and using textttsale and textttwoodwenv. The funtion header should look like this: funtion yy = larinet(f0, Aenv, Ienv, dur, fsamp) %CLARINET produe a larinet note signal % % usage: yy = larinet(f0, Aenv, Ienv, dur, fsamp) % % where: f0 = note frequeny % Aenv = the array holding the A(t) envelope % Ienv = the array holding the I(t) envelope % dur = the amount of time the signal lasts % fsamp = the sampling rate 6.5 Experiment with the Clarinet Sound Using your larinet( ) funtion, reate a 250 Hz larinet note with fs = 8000 or 11,025 Hz. Play it with the sound( xnote, fs ) funtion. Does it sound like a larinet? How an you verify that its fundamental frequeny is at 250 Hz? Explain how the modulation index I(t) will affet the frequeny ontent versus time of the larinet sound. Desribe how you an hear the frequeny ontent hanging aording to I(t)? Plot the instantaneous frequeny fi(t) versus t for omparison. Plot the entire signal and ompare it to the amplitude envelope funtion y1 in Fig. 1. Plot about 100 200 samples from the middle of the signal and explain what you see.