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

I need to add a function in my matlab code that can remove the noise in the code

ID: 3348727 • Letter: I

Question

I need to add a function in my matlab code that can remove the noise in the code shown below:

clc; clear all close all; fs 784; frequency 392; duration 50; amp 15; values [0:1/fs:duration]; mySound amp*sin(2*pi*frequency*values); max_val max(abs(mySound)); mySound mySound./max_val; filename- 'myAudioFile.wav'; audiowrite(filename,mySound,fs); [tune ,fs]-audioread(filename); %adding noise in this part noise energy 0.08 ; %here you can tune this with respect to signal bound noisySound-tune+ noise_energy * randn(length(tune), 1); % Find out which sound they want to play: promptMessage sprintf( Which sound do you want to hear?"); titleBarCaption 'Specify Sound'; button questdlg(promptMessage, titleBarCaption, 'Perfect, 'Noisy', 'Perfect'); if strcmpi(button, 'Perfect') % Play the perfect sound. isplay('Make sure your speakers are on.); display(Playing the audio...); sound(tune); else % Play the noisy sound display(Make sure your speakers are on.); display('Playing the audio...); sound(noisySound); end

Explanation / Answer

Below given are the steps involved in the coding:

%% read in the file

[tune,fs]= audioread(filename);

p1=audioplayer(tune,fs);

p1.play;

N=size(tune,1);

figure;

subplot(2,1,1);

stem(1:N,tune(:,1)); % tune is represented as matrix; left and right columns represent channels resp

title(‘Left channel’);

subplot (2,1,2);

stem(1:N,f(:,2));

title(‘Right channel’);

q=fs/N;

w=(-(N/2): (N/2)-1)*q;

x=fft(tune(:,1),N)/N;

x1=fftshift(x); % to center the spectrum

figure;

plot(w,abs(x1));

n=7; % choose the order of filter

bfq=i/(fs/2); % I, insert the starting value of the lower ranger of noise by inferring plot

efq=j/(fs/2); % j, insert the starting value of the higher ranger of noise by inferring plot

[b,a]=butter(n,[bfq,efq].’bandpass’);

fo=filter(b,a,tune); % fo is the filtered signal

p2=audioplayer(fo,fs);

p2.play;

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