Re: Chopping up a wav file and re-writing to disk
- From: "Dave Robinson" <dave.robinson@xxxxxxxxxxxxx>
- Date: Sun, 12 Mar 2006 10:31:55 -0500
Oli wrote:
Thanks Peter, I had a feeling I had missed something simple out,
but
didn't see that little error!
One more thing, do you know how I wouls go about plotting the
frequency spectrum of this 30 exerpt?
I tried 'plot(x,Fs)', but it displays nothing on the graph...
I am not quite sure why you expect that little plot to give you a
frequency spectrum, my understanding is that x is a fragment of your
time domain waveform, and Fs is your sample rate.
To get your frequency response you need to convert your time domain
waveform into the frequency domain - this is what the Fast Fourier
transform does
Freq_Response = fft(x);
The output of this operation gives you both the magnitude and phase
information of each frequency component, represented as a complex
number. If you are not interested in the phase, you can do one of two
things.
1) Compute the amplitude (magnitude) of each component
Magnitude = abs(Freq_Response);
2) Compute the power in each component
Power = Freq_Response*conj(Freq_Response);
To display this nicely go
Display_Freq = fftshift(Power); or
Display_Freq = fftshift(Magnitude);
Depending what you want to investigate, then try
plot(Display_Freq);
What you should see is a nice symmetrical waveform about the centre.
The centre point is DC or 0Hz, and represents the mean
power/amplitude of your segment of sound, To the right each sample
increases the frequency by 1/30Hz, so 30 samples upstream you are
looking at the power/magnitude of the signal at 1Hz. Going leftwards
your frequency is diminishing by 1/30Hz and represents the negative
frequencies, thus 30 samples downstream you have the component at
-1Hz, and because we have thrown away the phase information, it is
exactly the same values as the +1Hz component. Because of this
symmetry, many people will ignore the negative frequency components -
but if you do remember to double the value of all your frequency
components other than DC.
If you count the number of samples to your left from the DC point you
will find that the maximum negative frequency represented on this
graph is -Fs/2, and the maximum positive frequency is Fs/2.
You may want to scale your output logarithmically to get the power in
decibels.
Regards
Dave Robinson
.
- Follow-Ups:
- Re: Chopping up a wav file and re-writing to disk
- From: Dave Robinson
- Re: Chopping up a wav file and re-writing to disk
- References:
- Chopping up a wav file and re-writing to disk error - any ideas?
- From: Oliver
- Re: Chopping up a wav file and re-writing to disk error - any ideas?
- From: Peter Boettcher
- Re: Chopping up a wav file and re-writing to disk
- From: Oli
- Chopping up a wav file and re-writing to disk error - any ideas?
- Prev by Date: Re: Spam in this group and webx.raydaftYaTP
- Next by Date: Re: Advice needed for making a mex-file
- Previous by thread: Re: Chopping up a wav file and re-writing to disk
- Next by thread: Re: Chopping up a wav file and re-writing to disk
- Index(es):
Relevant Pages
|
Loading