MAE143A Signals & Systems - Homework 1, Winter 2015 — due by the end of class Friday January 16, 2014. Question 1 — matlab audio recording and playing Using matlab’s audiorecorder object, record a three-second segment of your own speech reading a plosive-laden text like “Peter Piper picked a peck of pickled peppers.” Do this at several sampling rate: 22050 Hz, 11025 Hz and 8000 Hz. Now record a sibilant-heavy text like “She sells sea shells by the sea shore.” Again do this as several different sampling rates. Experiment with these recordings at different bits-per-sample. Try 8 bits per sample and 16 bits per sample. Using the play function, play back these speech samples and comment briefly on the audio quality of each speech recording. matlab’s audiorecorder object is an example of a data structure. In programming, we use such things to store dissimilar data types under the one name. Thus audiorecorder contains: integer values like BitsPerSample, strings like StartFcn, and floating point real numbers like TimerPeriod. It also contains the data samples. To extract the data samples use the getaudiodata command, such as >> mv8=getaudiodata(myVoice88); Determine the size of the resulting data vector and construct the associated time vector for each speech sample. In general, the samples sound better with a higher bitrate that allows a broader dynamic range, and a higher sample rate that lets more high frequency content to be recorded without distortion. The data size can be found by using audioinfo command on the wave file, or by examining the data after audioread. To construct the time axis for a particular speech sample, one of the several ways is to use t = linspace(0,m/Fs,m) where m is the length of the sample and Fs is its sample rate. Question 2 — Plotting signals in matlab Part (i): Plot several recordings of your speech saying the same thing, such as the Peter Piper piece, but with variable sampling rates and on the one plot. Ensure that the all of the axes are labeled with (SI) units. Where the units are unknown just write (units) to indicate on the graph that the units are undefined. Ensure that the graph has an explanatory title and an explanatory legend. If necessary, use the placement property of the legend or use the plot editor to move the legend to an unobscuring location. Since we are plotting samples of speech, which is a discrete-time signal, we use symbols to plot the points and do not attribute meaning to lines joining the points. Although, once we understand this, we can join the dots. Part (ii) Using the sound function and your plot, identify some of the structural pieces of speech. For example, try to identify the p-sounds in Piper. You can examine pieces of speech via commands like >> sound(mv8(5000:10000),8000) [Try placing your finger on the side of your throat and feeling when your vocal chords vibrate, such as in the ‘er’ part of Peter. Connect this with the large amplitude of the signals in your plot.] Annotate your plot of one phrase by the phonemes (pieces of speech) comprising the signal. [Like I do on slide 12 of the notes of the website for a small piece.] Using the sound function make yourself sound like a chipmunk or a basso profundo. [Do not submit this.] Part (iii): For a speech signal sampled at 8 bits-per-sample, devise an approach to show graphically that the 24000-sample data vector consists only of 28 = 256 distinct sample values which are uniformly separated. Part(i): Appropriate SI units, legends, axis labels and titles are required for plots. Below is the plot of the 16-bit Peter Piper piece with variable sample rates. Plot of Peter Piper piece - 16-bit and variable sample rates 1 8000Hz 11025Hz 22050Hz 44100Hz 0.8 0.6 Speech signal (units) 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.5 1 1.5 Time (s) 2 2.5 3 Figure 1: Plot of the 16-bit Peter Piper speech sample with variable sample rates. Figure 2 is a zoomed-in segment of Figure 1 to show that a higher sample rate has more samples per unit time than a slower sample rate. Part(ii): Voiced phonemes, such as “er”, where the vocal cord is vibrating have large magnitude. This is shown by examining the plot. Figure 3 is the plot of the Peter Piper speech with a bitrate of 8 and a sample rate of 8000Hz with annotations showing the phonemes. Part(iii): Histogram of the speech sample can be plotted to demonstrate the levels in the sample. Alternatively sort can also be used. The plot needs to be zoomed in to see the equally separated levels. Figure 4 is the plot after sorting the Plot of Peter Piper piece - 16-bit and variable sample rates 0.14 8000Hz 11025Hz 22050Hz 44100Hz 0.12 Speech signal (units) 0.1 0.08 0.06 0.04 0.02 0 -0.02 1.274 1.276 1.278 Time (s) 1.28 1.282 1.284 Figure 2: Figure 1 zoomed in. samples in the signal and its zoomed-in version to better indicate the quantization levels. The speech signal may not be dynamic enough to cover the whole range 8-bit offers. And so the actual number of dynamic levels in the signal may be less than 256. matlab code for Question 2: [mv08_08,Fs08] = audioread(’mv08_08.wav’); t08 = linspace(0,length(mv08_08)/Fs08,length(mv08_08)); figure(1) plot(t08,mv08_08,’*’) title(’Plot of Peter Piper piece at 8-bit and 8000Hz’); xlabel(’Time (s)’);ylabel(’Speech signal (units)’); [mv08_16,Fs08] = audioread(’mv08_16.wav’); t08 = linspace(0,length(mv08_16)/Fs08,length(mv08_16)); [mv11_16,Fs11] = audioread(’mv11_16.wav’); t11 = linspace(0,length(mv11_16)/Fs11,length(mv11_16)); [mv22_16,Fs22] = audioread(’mv22_16.wav’); t22 = linspace(0,length(mv22_16)/Fs22,length(mv22_16)); [mv44_16,Fs44] = audioread(’mv44_16.wav’); t44 = linspace(0,length(mv44_16)/Fs44,length(mv44_16)); figure(2) plot(t08,mv08_16,’*’,t11,mv11_16,’o’,t22,mv22_16,’x’,t44,mv44_16,’d’) Figure 3: Plot of the 16-bit Peter Piper speech sample at 8-bit and 8000Hz title(’Plot of Peter Piper piece - 16-bit and variable sample rates’); xlabel(’Time (s)’);ylabel(’Speech signal (units)’); legend(’8000Hz’,’11025Hz’,’22050Hz’,’44100Hz’) figure(3) plot(sort(mv08_08)) title(’Plot of the 8-bit 8000Hz Peter Piper speech with samples sorted’); xlabel(’Samples sorted at each magnitude (units)’); ylabel(’Sample magnitude (units)’) Question 3 — Music signals in matlab and filtering Use the command audioread to load in the file Quadrant.wav from the class website. You might need to copy the file first. Determine the sampling rate used on this data call this Fs1. Call the data Q1. Compare sampling rate, data quantity/vector length, and the sound quality to the file Quadrant2dec.wav and to the file Quadrant8dec.wav. Particularly, pay attention to the prominence of the various percussion instruments. Call the sampling rate on the other signals Fs2 and Fs8 and the data Q2 and Q8 respectively. Extra (pure imaginary) point: Who is the drummer? Now use matlab to construct a Butterworth digital (i.e. discrete-tie) low-pass filter. >> [numbb,denbb] = butter(6,Fs2/Fs1) Next filter the discrete data from the first signal through this filter. >> Q1f = filter(numbb, denbb, Q1); Study the size of the resulting vector Q1f and use the appropriate sound command to play this. Zoomed sort of mv08_08 indicating distinct quantization levels -0.06 Plot of the 8-bit 8000Hz Peter Piper speech with samples sorted 1 0.8 -0.08 0.6 -0.1 sample value (units) Sample magnitude (units) 0.4 0.2 0 -0.2 -0.12 -0.14 -0.4 -0.16 -0.6 -0.8 -0.18 -1 0 0.5 1 1.5 Samples sorted at each magnitude (units) 2 2.5 ×10 4 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 sorted sample order (number) Figure 4: Plot of the 8-bit 8000Hz Peter Piper speech with samples sorted. How does this sound compared with Qf2? Try the same experiment with a high-pass Butterworth filter with the same cut-off frequency. Plot segments of the low-passed signal and plot the high-passed signal at the same times. Describe the differences that you see in the plots. Zoom in and then use the pan tool to find interesting details. Sample rate Fs1 = 4*Fs2 = 8*Fs8. The same ratio applies to the data size. Q1lf is the low passed version of Q1, and so it has the same data size as and sample rate as Q1. To play Q1lf using sound, use Fs1. Q2 on the other hand is a decimated version of Q1. Type help decimate in the command window for more information about decimate. The cut off frequency that decimate uses is .8*(Fs/2)/R. With Fs = Fs1 and R = Fs2/Fs1 = 1/4, the cut off frequency turns out to be 4410Hz, whereas the cut off frequency for Q1lf is 22050/4 = 5512.5Hz. Therefore Q1lf has more frequency content than Q2 and sounds better. As for the high passed version of Q1, denoted Q1hf using the Butterworth high pass filter and the same cut off frequency, only the frequency content higher than 5512.5Hz is passed through, e.g cymbals. Figure 5 is the plot of low passed and high passed versions of Q1 on the same graph. Note that each sample has 2 channels and the legend has to be constructed as such. Q1hf only have high frequency content that has lower energy than the low frequency content of Q1lf. This is shown in Figure 5. Also due to the high frequency content, when zoomed in as shown in Figure 6, the signal of Q1hf has shorter period than that of Q1lf, i.e the signal crosses the x-axis more often. The zoomed-in plot also shows that DC is eliminated after the high pass filter, indicated by the mean of the signal being closer to zero compared to that of the low passed version. matlab code for Question 3: [Q1,Fs1] = audioread(’Quadrant.wav’); [Q2,Fs2] = audioread(’Quadrant2dec.wav’); [Q8,Fs8] = audioread(’Quadrant8dec.wav’); Low passed and high passed versions of Q1 on the same plot 0.8 Q1lf Ch1 Q1lf Ch2 Q1hf Ch1 Q1hf Ch2 0.6 0.4 Signal (units) 0.2 0 -0.2 -0.4 -0.6 -0.8 0 5 10 Time (s) 15 20 25 Figure 5: Plot Q1lf and Q1hf. [numbb,denbb] = butter(6,Fs2/Fs1); Q1lf = filter(numbb, denbb, Q1); [numbh,denbh] = butter(6,Fs2/Fs1,’high’); Q1hf = filter(numbh, denbh, Q1); [m,n] = size(Q1lf); t = linspace(0,m/Fs1,m); plot(t,Q1lf,t,Q1hf) title(’Low passed and high passed versions of Q1 on the same plot’) xlabel(’Time (s)’);ylabel(’Signal (units)’); legend(’Q1lf Ch1’,’Q1lf Ch2’,’Q1hf Ch1’,’Q1hf Ch2’) Low passed and high passed versions of Q1 on the same plot 0.25 Q1lf Ch1 Q1lf Ch2 Q1hf Ch1 Q1hf Ch2 0.2 0.15 Signal (units) 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 2.6045 2.605 2.6055 2.606 Time (s) Figure 6: Plot Q1lf and Q1hf zoomed in. 2.6065
© Copyright 2026 Paperzz