Matlab help? DSP filters.

Discussion in 'Programmer's Corner' started by wavread, Mar 9, 2011.

  1. wavread

    Thread Starter New Member

    Mar 9, 2011
    2
    0
    Hello,
    I hope this is going in the right place on the board, but if not please tell me and I'll post elsewhere.
    Anywayy.
    As part of a project I have to import,play, analyse and then design a filter on Matlab to clean a piece of audio(WAVE). I've been going through the initial parts of importing the audio using Wavread, and playing using Wavplay, and that's all worked fine.
    However I'm at the analysing stage now, and my tutor has given me a code to use which I don't really understand, and so I can't really make anything out from the plot's I've got.
    So to get to the point I was wondering if anyone here had any idea of what the code I've used is doing? And if so how to interpret the plot's I've made with them.
    This is what I've got so far
    >> y=wavread('music14.wav');
    >> [y,fs]=wavread('music14.wav');
    >> wavplay(y,fs)
    >> mag=abs(fft(y));
    >> f=fs*(0:length(y)-1)/length(y);
    >> plot(f(1:500),mag(1:500))
    >> stem(f(1:500),mag(1:500))

    What's really confusing me is the section below. I'm just not sure what the code is trying to do.
    >> mag=abs(fft(y));
    >> f=fs*(0:length(y)-1)/length(y);

    And these are the graphs that came out.

    http://i52.tinypic.com/35an8md.jpg
    http://i53.tinypic.com/qsmi3p.jpg

    Do these mean that the filter I need to design needs to be a low pass, below 4500hz? or am I totally off the mark.

    Also, I vaguely know where to start designing the filter, but is it easy to implement the filter from the FDA tool in Matlab to the code? Or will it be better to code one?

    Any help is much appreciated.
     
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    The commands in question do nothing more than create a table of the magnitude Fast Fourier Transformation and the frequency axis.

    It seems strange though that the main frequencies don't go over 50Hz. Does that mirror in the actual track? Is the base dominant?

    The phrase "clean up the track" is a bit vague, but if I were you I would create a Low Pass filter with a corner frequency of 45Hz.

    I 'm not sure how you will do that, but I 'm sure Matlab Help will have plenty of examples.
     
  3. wavread

    Thread Starter New Member

    Mar 9, 2011
    2
    0
    Cheers for the quick reply.
    So, if I understand you properly. The section of code that I questioned is just to formulate a FFT and then put in a a graph?
    I found that a bit weird if I'm interperting the graphs correctly as well, because it's just a small section of an actual track, with a high pitched tone placed over the top of it, which is another reason I was going to try a low pass anyway, but I obviously have to correlate it back in to the plots and such.
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Notice that you are potentially plotting only a part of the actual Fourier graph, as you ask Matlab to draw only the first 500 elements. What I see is a steady bass beat with some noise on it, but maybe there is melody on the higher frequencies, above 75Hz.

    The corner frequency of your Low-Pass filter depends on what you want to do. Do you want to isolate the bass beat, or just erase high-pitch noise, typically above 2000Hz.
     
Loading...