changeset 33:5b7d90b6393a

Minor tweaks, still needs work.
author samer
date Sun, 20 Jan 2013 18:56:19 +0000
parents c3b0cd708782
children c75bb62b90a9
files dsp/constq.m dsp/cqbasis.m dsp/cqedges.m dsp/specbasis.m
diffstat 4 files changed, 30 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/dsp/constq.m	Sun Jan 20 13:48:47 2013 +0000
+++ b/dsp/constq.m	Sun Jan 20 18:56:19 2013 +0000
@@ -14,7 +14,7 @@
 %    [[L-1]]         ~ 'array of L-1 band edge frequencies'.
 
 parms=h_fparms(fs,hop,window);
-[S,times]=h_powspec(parms,signal);
+[S,times]=powspec(parms,signal);
 
 % 1000 Hz is the reference frequency for edge quantisation
 nedges=cqedges(fs,range,res,1000);
--- a/dsp/cqbasis.m	Sun Jan 20 13:48:47 2013 +0000
+++ b/dsp/cqbasis.m	Sun Jan 20 18:56:19 2013 +0000
@@ -1,5 +1,5 @@
-function [edges,map]=as_cqmap(parms,range,res)
-% as_cqmap - Audio Spectrum linear to log frequency map
+function [edges,map]=cqmap(parms,range,res)
+% cqmap - Audio Spectrum linear to log frequency map
 % 
 % Converts a constant-Q filterbank specification into a sparse matrix
 % which can be multiplied by a STFT power spectrogram to get a 
@@ -7,7 +7,7 @@
 % sampling grid has an adjustable spacing (the resolution parameter),
 % its origin is FIXED at 1kHz. 
 %
-% as_cqmap ::
+% cqmap ::
 %    struct {
 %       fs:real          ~ 'sampling rate',
 %       FFTsize:natural  ~ 'FFT frame size to be used to get STFT'
@@ -26,7 +26,7 @@
 	edges=min(range/parms.fs,0.5);
 else
 	F0=1000; % MAGIC number - origin of frequnecy grid is 1kHz
-	edges=as_cqedges(parms.fs,range,res,F0);
+	edges=cqedges(parms.fs,range,res,F0);
 
 	% remove edges from bottom end until each band can be resolved
 	e = 0.5+edges*parms.FFTsize;   % band edges relative to FT bin edges
--- 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
--- a/dsp/specbasis.m	Sun Jan 20 13:48:47 2013 +0000
+++ b/dsp/specbasis.m	Sun Jan 20 18:56:19 2013 +0000
@@ -1,14 +1,14 @@
 function map=specbasis(edges,M)
 % specbasis - Create frequency mapping matrix
-% 
-% Converts a filterbank specification into a sparse matrix for
-% mutliplying with a linear-frequency spectrogram.
 %
 % as_fmap ::
 %    [[L-1]]    ~ 'array of L-1 bin edge frequencies, in FT bins',
 %    M:natural  ~ 'number of bins in linear-freq spectrum'
 % ->
 %    [[L,M]]    ~ 'L-by-M sparse array'.
+% 
+% Converts a filterbank specification into a sparse matrix for
+% mutliplying with a linear-frequency spectrogram.
 %
 % Note, frequencies must measured in bins of the target spectrum,
 % Also, the first and last of the L bands are catch-alls which
@@ -16,23 +16,11 @@
 % respectively. If, eg, the bottom edge is 0, then the bottom
 % band will be empty.
 
-% 2005-01-15 Written - Samer Abdallah: to reproduce behaviour of
-%          a the function as_fmap_orig.m. It runs at about half
-%          the speed, but this version is only 8 lines of code!
-%          Also, this version doesn't barf if more than one band 
-%          edge falls in a frequency bin.
-%
-% 2005-01-29 SA: switched to measuring frequency in bins and specifying
-%          the size of the spectrum to be remapped. This makes the
-%          function more general in that it doesn't assume that
-%          1+N/2 bins are retained from an N-point FFT. In fact, the
-%          function is now independent of the FFT size.
-
-	E=repmat([0; edges(:); M-1],1,M);
-	I=repmat(0:M-1,length(edges)+1,1);
-	map=sparse(phi(E(2:end,:)-I)-phi(E(1:end-1,:)-I));
-	map=map.*(map>8e-15); % squeeze out more small values
-	map(:,2:end-1)=map(:,2:end-1)/2; % make up for top and bottom bins
+E=repmat([0; edges(:); M-1],1,M);
+I=repmat(0:M-1,length(edges)+1,1);
+map=sparse(phi(E(2:end,:)-I)-phi(E(1:end-1,:)-I));
+map=map.*(map>8e-15); % squeeze out more small values
+map(:,2:end-1)=map(:,2:end-1)/2; % make up for top and bottom bins
 
 %                                     ____
 % this is piecewise linear ramp : ___/