Starting from:

$30

EEE391-Homework 1 Sinusoidal Signals Solved

In this you are going to generate various sinusoidal signals and hear what sinusoids of different audible frequencies sound like, and experiment with some musical sounds. will extend our treatment of sinusoidal waveforms to more complicated signals composed of sums and products of sinusoidal signals or sinusoids with changing amplitude, frequency, or phase that are related to the basic sinusoid.

The Musical Scale
The frequencies 440 Hz and 880 Hz both correspond to the musical note A, but one octave apart. The next higher A in the musical scale would have the frequency 1760 Hz, twice 880 Hz. Thus, the following frequencies all correspond to the note A: 440 Hz, 440 × 2 = 880 Hz, 880 × 2 = 1760 Hz, 1760 × 2 = 3520 Hz.

In the western musical scale, there are 12 notes in every octave. These notes are evenly distributed (geometrically), so the next note above A, which is B flat, has frequency 440×β where β is the 12th root of two, or approximately 1.0595. The next note above B flat, which is B, has frequency 440 × β2, etc.

Below is a table of the complete musical scale between middle A and A-880. Each frequency is β times the frequency that comes before it.

                                                              musical note       frequency (Hz)



                                                                                   ♭♭)                      466

                                                                                   ♭♭)                      831



Table 1: Musical notes and the corresponding frequencies over one octave.

Part 1: Fundamental Frequency and Harmonics Consider a sinusoidal signal of the form

x1(t) = sin(2πfot).

Take fo = 440 Hz and evaluate the signal’s defining formula at discrete instants of time. These are called samples of the signal. In other words, discretize your signal at uniform sampling intervals of Ts = 0.0001 s using x1[n] = x1(nTs) over a duration of 3.0 s. Store the values of x1[n] in an array called x1. Plot x1 versus t over a duration of 0.01 s.

Type help plot in the MATLAB command window to see what you can do with the plot command which is one of the vital commands of MATLAB. Also study the MATLAB commands xlabel, ylabel, title, xlim, ylim, and grid. These commands are essential for producing professional looking plots in MATLAB. Make sure that you can properly use these commands.

Turn on the speakers of your computer. Examine the sound(.) and soundsc(.) commands of MATLAB by typing help sound and help soundsc in the MATLAB command window. Notice that soundsc(.) requires the sampling rate (frequency) at which the signal samples were created. Then, type sound(x1) or soundsc(x1). Listen to the sound. Repeat the same for 2fo = 880 Hz and 4fo = 1760 Hz. What happens to the pitch of the sound as the frequency increases?

The psychoacoustic properties of the musical scale are fascinating. The musical scale is based on our perception of frequency and harmonic relationships between frequencies. Frequencies that are harmonically related tend to sound good together. Among all the harmonic relationships in the scale, A, C sharp, and E have among the simplest. This possibly accounts for the predominance of the major triad in western music.

What about 440 × 3 = 1320 Hz? Notice that 1320/2 = 660 Hz, which is almost exactly the frequency of note E. Thus, 440 × 3 is the note E, one octave above the E immediately above A-440. E and A are harmonically related, and to most people, they sound good together. It is because 440 × 3 ≈ 659 × 2.

Where does the C sharp come from in the major triad? Notice that 440 × 5 ≈ 554 × 4.

Repeat the above exercise for the sinusoids corresponding to the notes C sharp and E and hear what these notes sound like.

Next, try combining A, C sharp, and E additively to create a major triad which can be expressed as a sum of sinusoids:

s(t) = sin(2π440t) + sin(2π554t) + sin(2π659t)

Writing a single line of code, compute s(t) for 3.0 s and store it in an array named s. Make a plot of the array s versus t and listen to s by the soundsc(.) command in the same way as you did above for x1. If you have musical background, you will recognize this sound as a major triad. What is special about this frequency combination?

For somewhat more arcane reasons, the interval between A and E, which is a frequency rise of 3/2, is called a fifth. The note 3/2 above E has the frequency 988 Hz, which is an octave above B-494. Another 3/2 above that is approximately F sharp (740 Hz). Continuing in this fashion, multiplying frequencies by 3/2, and then possibly dividing by two, you can approximately trace the 12 notes of the scale. This progression based on the choice of 12 evenly spaced notes corresponds to the so-called circle of fifths. The notion of key in music and a scale are based on this circle of fifths.

Musical sounds such as chords can be characterized as sums of pure tones. Of course, truly musical sounds are much more complex. For one thing, pure tones are not particularly appealing sounds. Musical instruments produce notes that are more complex than pure tones. The characteristic sound of an instrument is its timbre and some aspects of timbre can also be characterized as sums of sinusoids.

Part 2: The Effect of Phase

Let x2(t) = cos(2πfot + φ) where fo = 587 Hz corresponding to the note D.

a)   Let φ = 0. Compute, plot, and listen to x2(t) in the same way as in Part 1.

b)  Repeat for rad.

How does the volume of the sound that you hear change with φ? How does the pitch of the sound that you hear change with φ?

Part 3: Sinusoid with Exponentially Decaying Envelope Now consider the signal defined as

x3(t) = e−(a2+2)t cos(2πfot).

Take a = 2 and fo = 440 Hz. Writing a single line of code, compute x3(t) and store it in an array named x3. In this code, make use of the element-wise multiplication facility of MATLAB while computing the product of e−(a2+2)t and cos(2πfot). (Recall that in MATLAB, element-wise multiplication of arrays is achieved by placing a dot in front of the multiplication symbol. (You can examine the examples provided in the MATLAB exercises on the course web page.) Provide this code in your report. Make a plot of x3 versus t and listen to x3 by the soundsc(.) command in the same way as you did in Part 1. Compare your plot and what you hear to the results you obtained for x1(t) when fo is 440 Hz. What is the effect of including the exponential term to the sound that you hear? Which one of x1(t) and x2(t) resembles the sound produced by a piano more? Which one resembles that of a flute more? Now take a = 1, and recompute x3 (do not change fo and t). Compare the sound you hear with that of the a = 2 case. Repeat for a = 3. How does the duration of the sound that you hear change as a increases? Can you relate this signal model to a physical system that we discussed in class that produces sinusoidal signals?

Part 4: Beat Notes and Amplitude Modulation

When we multiply two sinusoids having different frequencies, we can create an interesting audio effect called a beat note. The phenomenon, which may sound like a warble, is best heard by picking one of the frequencies very small (e.g., 10 Hz) and the other around 1 kHz in the multiplicative form of two sinusoids. Thus, consider the product of two cosine signals:

x4(t) = cos(2πf1t)cos(2πf2t)

where f1 ≪ f2. Take f1 = 10 Hz and f2 = 1000 Hz. Again using a single line command, compute the array x4 (provide this code in your report), plot and listen to it in the same way as in Part 1. Compare your results with those of x1(t) in Part 1. What is the effect of the low-frequency cosine term cos(2πf1t) on the sound that you hear? Recompute x4 for f1 = 5 Hz and f1 = 15 Hz. How does the sound that you hear change? By using the

well-known trigonometric identity

,

express x4(t) as the sum of two different-frequency cosine signals and also interpret what you hear in this part using this equality. Picking two or three frequencies very close together in the additive form of sinusoids generates beat signals, which is the case here.

Some musical instruments naturally produce beating notes. Musicians use this beating phenomenon as an aid in tuning two instruments to the same pitch. When two notes are close but not identical in frequency, the beating phenomenon is heard. As one pitch is changed to become closer to the other, the effect disappears, and the two instruments are then “in tune.”

Another use for multiplying sinusoids is modulation for radio broadcasting and communication systems. For example, AM radio stations use this method, which is called amplitude (AM) modulation. This is the process of multiplying a low-frequency signal v(t) by a high-frequency sinusoid. Thus, an AM signal is a product of the form:

x(t) = v(t)cos(2πfct)

where it is assumed that the frequency of the cosine term is much higher than any frequency contained in the spectrum of v(t), which represents the voice or music signal to be transmitted. The cosine wave is called the carrier signal and its frequency is called the carrier frequency.

Part 5: Chirp Signals and Frequency Modulation

We will also consider signals whose frequency varies as a function of time. The argument of the constant-frequency sinusoid is (2πfot + φ). This angle function changes linearly versus time, and its time derivative is ωo = 2πfo which equals the constant frequency of the cosine in rad/s.

A generalization is available if we adopt the following notation for the class of signals represented by a cosine function with a time-varying angle:

x(t) = Acos[ψ(t)]

The time derivative of the angle in the above equation gives a radian frequency changing with time:

                                                                                                   )          (rad/s)

but we prefer the cyclic frequency, therefore, we divide by 2π to define the instantaneous frequency:

                                                                     )           (Hz)

A chirp signal is a sinusoid whose frequency is linearly swept so that it changes linearly from a starting value to an ending one. The formula for such a signal can be obtained by creating a quadratic angle by defining ψ(t) as:

ψ(t) = 2πµt2 + 2πfot + φ.

The time derivative of ψ(t) yields an instantaneous frequency that changes linearly versus time fi(t) = 2µt + fo.

The slope of fi(t) is equal to 2µ and its intercept is equal to fo. If the signal starts at time t = 0 s, then fo is also the starting frequency. The frequency variation produced by such a time-varying angle is called frequency (FM) modulation. This kind of signal is an example of a frequency modulated signal. More generally, we often consider them to be part of a larger class called angle modulated signals. Finally, since the linear variation of the frequency can produce an audible sound similar to a siren or a chirp, the linear-FM signals are also called “chirps.” In nature, animals such as bats and dolphins produce chirp signals in the ultrasonic frequency range for echolocation and communication.

To get a feeling about the physical implication of the linearly changing instantaneous frequency, let us compute x5(t) = cos(2πµt2 + 2πfot + φ) and listen to it. As a test case, generate a chirp signal whose frequency starts at 2500 Hz and ends at 500 Hz over a time duration of 2.0 s. Use a sampling interval of Ts = 0.01 s. Calculate the value of µ. Listen to the chirp using the soundsc(.) function. Then modify it so that the starting frequency is 500 Hz and ending frequency is 2500 Hz for the same duration. Listen to the chirp using the soundsc(.) function again. How is it different from the first chirp? What happens if you double the µ coefficient? What happens if you halve it? Comment on the changes you observe in your report.

A Chirp Puzzle



Synthesize another chirp signal with the following parameters:

A total time duration of 3.0 s, with a sampling interval of Ts = 0.01 s.

The instantaneous frequency starts at 3000 Hz and ends at –2000 Hz (negative frequency).

Listen to the signal. Does it chirp down, chirp up, or both? Use the theory of the frequency spectrum (with its positive and negative frequency components) to help explain what you hear. The changing instantaneous frequency implies that the frequency components in the spectrum are moving.

Part 6: Composing Music

Write the following function:

function [note] = notecreate(frq no, dur)

note = sin(2*pi*[1:dur]/8192*(440*2.^((frqno-1)/12)));

end

Then, write the following script:

notename = [‘‘A’’, ‘‘A#’’, ‘‘B’’, ‘‘C’’, ‘‘C#’’, ‘‘D’’, ‘‘D#’’, ‘‘E’’,

‘‘F’’, ‘‘F#’’, ‘‘G’’, ‘‘G#’’]; song = [‘‘A’’, ‘‘A’’, ‘‘E’’, ‘‘E’’, ‘‘F#’’, ‘‘F#’’, ‘‘E’’, ‘‘E’’, ‘‘D’’,

‘‘D’’, ‘‘C#’’, ‘‘C#’’, ‘‘B’’, ‘‘B’’, ‘‘A’’, ‘‘A’’]; for k1 = 1:length(song)

idx = strcmp(song(k1), notename); songidx(k1) = find(idx);

end dur = 0.3*8192; songnote = [ ]; for k1 = 1:length(songidx)

songnote = [songnote; [notecreate(songidx(k1),dur) zeros(1,75)]’];

end soundsc(songnote, 8192)

More products