Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<p>I need to write a program that generates notes c-cleff. The function should o

ID: 3634159 • Letter: #

Question

<p>I need to write a program that generates notes c-cleff. The function should output a vector of samples of a note at the specified sampling rate and for the specified duration. Typical duration value for a quarter note is 0.15 seconds and an acceptable sampling rate is 10,000 samples per second. The function should be called "mytone." i must write the main program that calls on mytone for notes in a song so that my program plays "Mary had a little lamb". BELOW IS WHAT I HAVE DONE SO FAR AND WHERE I AM STUCK.</p>
<p>This is the tone function that i have come up with.</p>
<p>function [x] = Tone (fo, tduration)<br /><br />fs=5000;<br />ts=1/fs;<br />t=0:ts:tduration;<br />x=sin(2*pi*fo*t);<br /><br />end</p>
<p>Now I need to call "mytone" function so i can play the notes, this is what i have so far but it is not working and i cant hear any sounds.</p>
<p>fs=8000<br />a = Tone(4000,.1)<br />x=[x a]<br /><br />soundsc(x,fs)</p>

Explanation / Answer

I need to write a program that generates notes c-cleff. The function should output a vector of samples of a note at the specified sampling rate and for the specified duration. Typical duration value for a quarter note is 0.15 seconds and an acceptable sampling rate is 10,000 samples per second. The function should be called "mytone." i must write the main program that calls on mytone for notes in a song so that my program plays "Mary had a little lamb". BELOW IS WHAT I HAVE DONE SO FAR AND WHERE I AM STUCK.

This is the tone function that i have come up with.

function [x] = Tone (fo, tduration)

fs=5000;
ts=1/fs;
t=0:ts:tduration;
x=sin(2*pi*fo*t);

end

Now I need to call "mytone" function so i can play the notes, this is what i have so far but it is not working and i cant hear any sounds.

fs=8000
a = Tone(4000,.1)
x=[x a]

soundsc(x,fs)

my version goes as follows

% pure tones

clear

freqs = 5000;
duration = 0.1;

for i = 1:length(freqs)

sampleFreq = 44100;
dt = 1/sampleFreq;

t = [0:dt:duration];

s=sin(2*pi*freqs(i)*t);
sound(s,sampleFreq);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote