Line 66: Line 66:
 
===Answer 5===
 
===Answer 5===
 
samplerate=1/44100;  
 
samplerate=1/44100;  
t1=0:samplerate:5;  
+
 
x=cos(440*2*pi*t1);  
+
t1=0:samplerate:5;
 +
 +
x=cos(440*2*pi*t1);
 +
 
sound(x,1/samplerate);
 
sound(x,1/samplerate);
I just picked the sampling rate  
+
 
 +
I just picked the sampling rate
 +
 
because it is most commonly used rate for digital audio such as MP3.
 
because it is most commonly used rate for digital audio such as MP3.
 +
 
This sampling rate is sufficient for anything in the hearing range.
 
This sampling rate is sufficient for anything in the hearing range.
  

Revision as of 18:12, 6 September 2011

Sampling of an A 440

Explain how one can use MATLAB to play an A 440. Discuss your choice of sampling rate. (Feel free to post a sound file of your output.)


Share your answers below

You will receive feedback from your instructor and TA directly on this page. Other students are welcome to comment/discuss/point out mistakes/ask questions too!


Answer 1

The signal we want is $ x(t) = cos(440 * 2\pi) $.

We can first create a vector of sample times. In this case, we'll let the sample frequency be 1320 Hz over a sample interval of [0,1]

t = 0:(1/1320):1;

Next, we can generate the sound samples vector from the sample times vector.

y = cos(440*2*pi*t);

Finally, we play the signal by using the "sound" command, which needs the user to specify the sound vector and the sample rate of that vector. Our sample was 1320.

sound(y, 1320);

The sample frequency was chosen so that it was more than twice the note frequency, so that the signal could be completely recovered from this sample.

Instructor's comments: Did you actually try it in MATLAB? Did it work? -pm

Answer 2

I chose the sample rate to be 1/1000.

n = 1:10000;

x = cos(2*pi*400*n/1000);

x = x';

sound(x)


Answer 3

% The following script plays a pure note A-440.

% It provides an adjustable sampling rate.

sampling_rate = 1500;

% Sampling rate should be larger than Nyquist Rate, i.e. 880Hz in this case.

t = 1:(1/sampling_rate):3;

x = cos(2*pi*440*t);

sound(x,sampling_rate);

%Code had been verified on MATLAB R2010b

Answer 4

rate=1/1000 t=0:rate:5; x=cos(440*2*pi*t); sound(x,1/rate)

the code works

Answer 5

samplerate=1/44100;

t1=0:samplerate:5;

x=cos(440*2*pi*t1);

sound(x,1/samplerate);

I just picked the sampling rate

because it is most commonly used rate for digital audio such as MP3.

This sampling rate is sufficient for anything in the hearing range.




Back to ECE438 Fall 2011 Prof. Boutin

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett