function [X, times, edges] = constq(range,res,hop,window,fs,signal)
% as_constq - Constant Q spectrogram.
%
% as_constq ::
%    [[2]]           ~ 'frequency range as a two-element array, [low high]',
%    real            ~ 'resolution in octaves',
%    natural | [[2]]	~ 'hop size, either in samples, or as a rational',
%    natural | [[2]]	~ 'window size, either in samples, or as a rational',
%    real            ~ 'sampling frequency',
%    [[T]]           ~ 'signal of length T'
% ->
%    [[L,M]]         ~ 'L-by-M array containing L-band spectral envelopes',
%    [[1,M]]         ~ 'array of nominal sampling time for each frame',
%    [[L-1]]         ~ 'array of L-1 band edge frequencies'.

parms=h_fparms(fs,hop,window);
[S,times]=powspec(parms,signal);

% 1000 Hz is the reference frequency for edge quantisation
nedges=cqedges(fs,range,res,1000);
X=specbasis(parms.FFTsize*nedges,size(S,1))*S;
edges=fs*nedges;

