Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

removing noise from an Audio file in matlab using notch filter using (1 - exp...)

Status
Not open for further replies.

zxz2

Newbie level 2
Newbie level 2
Joined
May 22, 2016
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
27
hello everyone , i need help please , i need to write a matlab code that reads an audio file and removes the noise at frequency of 1000 hz.
the noise must be also added manualy in matlab code. after that filter it.
the frequency response can be designed in the form (1 - exp...)(1 - exp...), where
the complex exponentials have to be designed to be 1 at f0 and ?f0 respectively.
please help me with this , this is the only way i can learn by following the steps , step by step to understand matlab code and learn more .
many thanks
 

the frequency response can be designed in the form (1 - exp...)(1 - exp...),
where the complex exponentials have to be designed to be 1 at f0 and ??f0 respectively.
This shows a transfer function of cascaded differentiator.
https://en.wikipedia.org/wiki/Comb_filter

please help me with this,
this is the only way i can learn by following the steps , step by step
to understand matlab code and learn more.
Describe what you want to do in detal and correctly.

Is your question how to write m-file for cascaded differentiator ?

https://jp.mathworks.com/help/dsp/examples/design-of-peaking-and-notching-filters.html?lang=en
 
Last edited:

Hi,

NOISE is a mixture of a lot of frequencies with varying amplitude.

This is difficult to filter.

If you want to attenuate frequencies around 1kHz then you need a band stop filter.

Klaus
 

thanks for the reply , here is exactly what i have to do :
i have to add noise to a wav file , then remove it by removing the frequency at 1kHz . using a notch filter in matlab.
so i have to write a code for that , but i cant use the built in notch function. must write the code "logic" behind it alone using the (1- exp ...)(1- exp ...) logic.

would that code be right? if yes what i have to change so i cut off the 1khz frequency (my noise is at the frequency)
thanks in advance :)

Code:
% Andre Lundkvist and Rikard Qvarnstrm
%
% Lab 1
% Filter Design and Evaluation in MATLAB
6 function lab1 ( assignment )
clc ;
close a ll ;

if nargin < 1
assignment = 3;
end

% Note to self:
% use profile to check performance
prof = false ;
if prof == true
profile on ;
t i c ;
end

[x, fs ] = wavread( ’boyNY .wav ’);

% Chose which assignment to run:
switch assignment

case 1
% Code for Assignment 1 <here>

case 2
% See the myfilter() function

case 3
% Code for Assignment 3 <here>

case 4
% Code for Assignment 4 <here>

case 5
% Code for Assignment 5 <here>

otherwise
% If input does not match assignment:
fpr int f( ’Wrong input \n ’);

end

if prof == true
profile off ;
profile viewer ;
trun = toc;
fpr int f (’Total time elapsed = % g\n’,trun );
end
fpr int f( ’\n ’);
end

A.2 Lab 1 - Assignment 1
Code:
% Andre Lundkvist and Rikard Qvarnstrm
%
% Lab 1, Assignment 1
% Notch filter design

% Analysis
h = spectrum . periodogram ;
hpsd = psd (h ,x, ’Fs ’,fs);
figure ; % fig 1
plot( hpsd )
t i t l e (’Assignment 1 - Periodogram Power Spectral Density Estimate ’);
print - depsc - tiff - r300 Lab_1_Ass_1_PSD

fx = real ( ff t (x ,fs ));
freq = find (fx == max(fx )) ; % find the most dominating frequencys
freq (2) = fs - freq (2) ;
meanfreq = mean( freq ) ; % take the mean of the 2 detected peaks

%figure;
%plot(fx);
%axis([0 fs/2 min(fx) max(fx)]);

% Design
angle = 2* pi * meanfreq /fs ; % the angle for the zeroes placement
B = [1 -2* cos(angle ) cos(angle) ^2+ sin(angle ) ^2]; % polynomial coefficients
A = [1 0 0]; % two poles in the center of the unit circle
[hplot , fplot ]= freqz (B ,A,fs , fs);

figure ; % fig 2
zplane (B,A); % the pole and zeroes plot
t i t l e (’Assignment 1 - Pole / Zero plot ’);
print - depsc - tiff - r300 Lab_1_Ass_1_PZ

figure ; 
% fig 3
freqzplot (hplot , fplot , ’Hz ’); % bode plot (frequency and phase)
t i t l e (’Assignment 1 - Bode plot ’);
print - depsc - tiff - r300 Lab_1_Ass_1_Bode

% Filter the input
xf = fil t e r (B , A , x);

% Play the music files
%sound(x, fs); % original file
%sound(xf, fs); % After filtering
 
Last edited by a moderator:

would that code be right? if yes what i have to change so i cut off the 1khz frequency

Why don't you show all the plotted outputs, and what's not working as expected ?
 

Why don't you show all the plotted outputs, and what's not working as expected ?

If I understand you correctly, the desired result can be obtained by taking a Fourier transformation (that will convert it into a frequency domain) and then removing the point (or points) corresponding to 1kHz and then Fourier transforming that again back to the audio result.
 

If I understand you correctly, the desired result can be obtained by taking a Fourier transformation (that will convert it into a frequency domain) and then removing the point (or points) corresponding to 1kHz and then Fourier transforming that again back to the audio result.

Apparently it was already made to the input signals.
The same should be done to the signal after being 1Khz filtered.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top