help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Acoustics


From: Doug Stewart
Subject: Re: Acoustics
Date: Wed, 24 Nov 2010 07:12:30 -0500

On Wed, Nov 24, 2010 at 6:27 AM, Daniel Arteaga
<address@hidden> wrote:
> Al 21/11/10 16:54, En/na Martin Maxino ha escrit:
>>
>> Will anyone please direct me to examples of how to use Octave to analyze
>> sound (FFTs, etc.).
>>
>> It would be greatly appreciated.
>
> For instance, to analyze the spectrum of an audio file:
>
> [audio,fs] = wavread ("audiofile.wav");
> n = length(audio);              #Number of samples
> t = n/fs;                       #Duration in s
> N = floor(n/2);
> temp = fft(audio,2*n+1);
> dc = temp(1);
> audio_fft = temp(2:n+1);
> freq_vector = linspace(0,fs,2*n+1)(2:n+1);
> spectrum_dB = 20*log10(abs(audio_fft));
> phase = arg(audio_fft);
> figure;
> semilogx(freq_vector,spectrum_dB);
> figure;
> semilogx(freq_vector,phase);
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>

I would suggest a small improvement

"
temp = fft(audio,2*n+1);
dc = temp(1);
audio_fft = temp(2:n+1);
"

I would do
temp = fft(audio,2*n+1);
dc = temp(1);
audio_fft = temp;
audio_fft(1)=0;

This will set the DC to zero but not shift all frequencies down 1 bin.

Doug Stewart



reply via email to

[Prev in Thread] Current Thread [Next in Thread]