commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Kr├╝ger <C.Krue...@gmx.org>
Subject Re: [math] transform - fft documentation bug? proposal window function & sonogram
Date Mon, 10 Dec 2007 02:12:51 GMT
> they are.  I'm -0 on the spectrogram, having personally spent time
> trying to use a naive spectrogram as a power spectrum estimator.  I
> only spent enough time on that task
> to come to the understanding that it wasn't as simple as it seemed
> it should be.

it is easy, example Matlab code (maybe works in Octave or Scilab)

only "calc the spectrogram" should be implemented in commons.apache.org

------------------------------------------------------------------------------------
clear; clc;

% read sound
[sound fs nbits] = wavread('test.wav');
sound = sound(:,1);

% sonagram parameters
fftsize = 8192;
overlap = 15/16;
window = hann(fftsize);

stepsize = floor(fftsize - (fftsize * overlap));
% initialise memory
sona = zeros(fftsize/2+1, floor((length(sound)-round(overlap*fftsize))/stepsize));

% calc the spectrogram
index = 1;
for pos=1:stepsize:length(sound)-fftsize,
    spectrum = fft(window .* sound(pos:pos + fftsize - 1));
    sona(:, index) = spectrum(1:fftsize/2+1);
    index = index + 1;
end;

% show graphic
[row column] = size(sona);
t = 1:column;
f = 1:row;
surf(t,f,10*log10(abs(sona)),'EdgeColor','none');
axis xy; axis tight; colormap(Jet); view(0,90);
------------------------------------------------------------------------------------

> I would prefer that the package provide a function that "does what most people think
of when
> thinking about a spectrogram" rather than the naive spectrogram.

it does exactly the same that Audacity, Wavelab, Raven etc. does

greetings
Carsten


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message