samer@32
|
1 function edges=as_cqedges(fs,range,res,F0)
|
samer@32
|
2
|
samer@32
|
3 % as_cqedges - Audio Spectrum linear to log frequency map (no checking)
|
samer@32
|
4 %
|
samer@32
|
5 % Converts a constant-Q filterbank specification into a list of band
|
samer@32
|
6 % edges, and optionally the sparse mapping matrix
|
samer@32
|
7 % which can be multiplied by a STFT power spectrogram to get a
|
samer@32
|
8 % constant-Q spectrogram.
|
samer@32
|
9 %
|
samer@32
|
10 % as_cqmap0 ::
|
samer@32
|
11 % real ~ 'sampling rate',
|
samer@32
|
12 % [[2]] ~ 'requested lower and upper cut-off frequencies',
|
samer@32
|
13 % real ~ 'resolution in octaves',
|
samer@32
|
14 % real ~ 'origin of frequency grid in Hz (defaut=1kHz)'
|
samer@32
|
15 % ->
|
samer@32
|
16 % [[L-1]] ~ 'frequency bin edges',
|
samer@32
|
17 % [[L,M]] ~ 'L by M sparse array'.
|
samer@32
|
18
|
samer@32
|
19 % origin of frequnecy grid defaults to 1kHz
|
samer@32
|
20 if nargin<4, F0=1000; end
|
samer@32
|
21
|
samer@32
|
22 % quantise requested edges and represent them in
|
samer@32
|
23 % in units of res on a log frequency scale.
|
samer@32
|
24 limits = round(log2(range/F0)/res);
|
samer@32
|
25
|
samer@32
|
26 % convert to normalised frequencies (fs=1)
|
samer@32
|
27 edges = (F0/fs)*2.^(res*(limits(1):limits(2)));
|
samer@32
|
28
|
samer@32
|
29 % remove any edges above Nyquist rate
|
samer@32
|
30 if edges(end)>=0.5, edges = edges(edges<0.5); end
|