Digital filtering

Thread Starter

Cerkit

Joined Jan 4, 2009
287
Hi. I have been given some audio files and need to make filters in MATLAB to remove some intentionally added noise. I know how to make filters but not sure how to determine what to let through and what to block how can I identify this from the audio files??
 

Dave

Joined Nov 17, 2003
6,970
Hi. I have been given some audio files and need to make filters in MATLAB to remove some intentionally added noise. I know how to make filters but not sure how to determine what to let through and what to block how can I identify this from the audio files??
Assuming you know how to characterise the noise, i.e. frequency components, and have an appropriate filter characterised in the frequency-domain, then you need to read in your audio file to Matlab (this will, depending on function, likely be the time-domain representation). Then you need to convert the time-domain representation to a frequency-domain representation via the Fourier Transform (function fft), and then apply your filter via simple multiplication ([fd_sig].*[filter]).

That is a basic model, however you specific case may be more involved.

Dave
 

Dave

Joined Nov 17, 2003
6,970
Why would someone intentionally add noise to a digital audio file?

John
John,

Aside from the example here of doing it for the purposes of creating an academic exercise to simulate a real audio filtering application, the most obvious real world example I can think of is audio watermarking which can be used in DRM, where the watermark is the embedded "noise".

Dave
 

Thread Starter

Cerkit

Joined Jan 4, 2009
287
Hi. I've made a butterworth IIR filter in matlab using fdatool. How can I apply it to a .wav audio file???
 

Dave

Joined Nov 17, 2003
6,970
Hi. I've made a butterworth IIR filter in matlab using fdatool. How can I apply it to a .wav audio file???
Cerkit, I have merged this thread with your previous one as they are fundamentally asking the same question, and the advice I gave last time is applicable here.

Firstly, I am vaguely familiar with the fdatool function, can you tell us what the output from it is? For a Butterworth filter you want an [n x 1] matrix defining the magnitude Vs Frequency characteristic of the filter - in fact each element in the matrix will describe the magnitude at discrete frequencies so I imagine it will also give you a frequency resolution (i.e. the difference in frequency between adjacent elements in the matrix).

You then need to read in the wav-file using the wavread function, which will give you a time-domain description of the wav-file. Then you need to apply the Fourier Transform, function fft, to get the wav-file in the frequency-domain. You will need to ensure that the frequency elements in the frequency-domain representation of the wav-file correspond to the appropriate frequency elements in the Butterworth filter matrix. It is then a simple process of multiplying these two matrices, which performs the filtering process. Then apply the Inverse Fourier Transform, function ifft, to the multiplied matrix to get the filtered wav-file back in the time domain. Finally, use wavwrite to write the filtered time-domain representation of the wav-file into an actual Microsoft wav-file that you can listen to.

Dave
 

KL7AJ

Joined Nov 4, 2008
2,229
John,

Aside from the example here of doing it for the purposes of creating an academic exercise to simulate a real audio filtering application, the most obvious real world example I can think of is audio watermarking which can be used in DRM, where the watermark is the embedded "noise".

Dave

The addition of noise to digitized audio "dithering" is actually fairly standard practice. It adds some randomness the the least significant bit during the sampling process, which actually decreases "sampling distortion" in one of the great paradoxes of nature. :)

http://www.earlevel.com/Digital%20Audio/Dither.html

This is from my brother-in-law's web site, EarLevel Engineering. He's one of the co-creators of MIDI, by the way. :)

eric

eric
 

Thread Starter

Cerkit

Joined Jan 4, 2009
287
Hi. Ok so I have the Xk = fft(wxn) so Xk is my wav file in frequency domain. My filter is made of three butterworth filters cascaded and when I export the coefficients it creates a variable which is of type 1x3cell. I try multiplyng the XK and coeff but its not working. Do i have to change the coeffiecients somehow before multiplying??
 

Thread Starter

Cerkit

Joined Jan 4, 2009
287
Or rather I can export them individually as the SOS and scaling factor but dont know how to cascade them using code or apply the filter for that matter??
 
Top