Mercurial > hg > ishara
diff dsp/cqedges.m @ 33:5b7d90b6393a
Minor tweaks, still needs work.
author | samer |
---|---|
date | Sun, 20 Jan 2013 18:56:19 +0000 |
parents | c3b0cd708782 |
children |
line wrap: on
line diff
--- a/dsp/cqedges.m Sun Jan 20 13:48:47 2013 +0000 +++ b/dsp/cqedges.m Sun Jan 20 18:56:19 2013 +0000 @@ -1,30 +1,26 @@ -function edges=as_cqedges(fs,range,res,F0) - -% as_cqedges - Audio Spectrum linear to log frequency map (no checking) -% -% Converts a constant-Q filterbank specification into a list of band -% edges, and optionally the sparse mapping matrix -% which can be multiplied by a STFT power spectrogram to get a -% constant-Q spectrogram. +% cqedges - Audio Spectrum linear to log frequency map (no checking) % -% as_cqmap0 :: +% cqedges :: % real ~ 'sampling rate', % [[2]] ~ 'requested lower and upper cut-off frequencies', % real ~ 'resolution in octaves', % real ~ 'origin of frequency grid in Hz (defaut=1kHz)' -% -> -% [[L-1]] ~ 'frequency bin edges', -% [[L,M]] ~ 'L by M sparse array'. +% -> [[L-1]] ~ 'frequency bin edges'. +% +% Converts a constant-Q filterbank specification into a list of band edges. -% origin of frequnecy grid defaults to 1kHz -if nargin<4, F0=1000; end +function edges=cqedges(fs,range,res,F0) + % origin of frequnecy grid defaults to 1kHz + if nargin<4, F0=1000; end -% quantise requested edges and represent them in -% in units of res on a log frequency scale. -limits = round(log2(range/F0)/res); + % quantise requested edges and represent them in + % in units of res on a log frequency scale. + limits = round(log2(range/F0)/res); -% convert to normalised frequencies (fs=1) -edges = (F0/fs)*2.^(res*(limits(1):limits(2))); + % convert to normalised frequencies (fs=1) + edges = (F0/fs)*2.^(res*(limits(1):limits(2))); +keyboard -% remove any edges above Nyquist rate -if edges(end)>=0.5, edges = edges(edges<0.5); end + % remove any edges above Nyquist rate + if edges(end)>=0.5, edges = edges(edges<0.5); end +end