Skip to content

Commit

Permalink
renamed the *lengthsignal function to *length
Browse files Browse the repository at this point in the history
  • Loading branch information
psoenderg committed Sep 12, 2012
1 parent fef1bb5 commit b73adea
Show file tree
Hide file tree
Showing 32 changed files with 219 additions and 187 deletions.
2 changes: 1 addition & 1 deletion comp/comp_fourierwindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
firwinnames = {'hanning','hann','sine','cosine','sqrthan','sqrthann','hamming',...
'sqrtham','square','rect','sqrtsquare','sqrtrect',...
'tria','triangular','sqrttria','blackman','blackman2','nuttall'...
'ogg'};
'ogg','itersine'};

% Create window if string was given as input.
if ischar(g)
Expand Down
70 changes: 70 additions & 0 deletions comp/comp_nonsepdgt_shear.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function c=comp_nonsepdgt_shear(f,g,a,M,s0,s1,X)
%COMP_NONSEPDGT_SHEAR Non-sep DGT using the shear algorithm
% Usage: c=comp_nonsepdgt_shear(f,g,a,M);
%
% Input parameters:
% f : Factored input data
% g : Window.
% a : Length of time shift.
% M : Number of channels.
% s0 : s0 from shearfind
% s1 : s1 from shearfind
% X : X from shearfind
% Output parameters:
% c : M x N*W*R array of coefficients, where N=L/a
%
% Do not call this function directly, use NONSEPDGT instead.
% This function does not check input parameters!

% AUTHOR : Nicki Holighaus and Peter L. Soendergaard

L=size(f,1);
W=size(f,2);

b=L/M;
N=L/a;

if s1 ~= 0
g = pchirp(L,s1).*g;
f = repmat(pchirp(L,s1),1,W).*f;
end

if s0 ~= 0
g = ifft(pchirp(L,-s0).*fft(g));
f = ifft(repmat(pchirp(L,-s0),1,W).*fft(f));
end;

br = X;
ar = a*b/X;
Mr = L/br;
c_rect = comp_dgt(f,g,ar,Mr,L,0);

ind = [ar 0; 0 br]*[kron((0:L/ar-1),ones(1,L/br));kron(ones(1,L/ar), ...
(0:L/br-1))];
phs = reshape(mod((s1*(ind(1,:)-s0*ind(2,:)).^2+s0*ind(2,:).^2)*...
(L+1),2*L),L/br,L/ar);
phs = exp(pi*1i*phs/L);

for w=1:W
c_rect(:,:,w) = phs.*c_rect(:,:,w);
end;

ind_final = [1 0;-s1 1]*[1 -s0;0 1]*ind;
ind_final = mod(ind_final,L);

c = zeros(M,N,W);

% The code line below this comment executes the commented for-loop
% using Fortran indexing.
%
% for jj = 1:size(ind,2)
% c2(floor(ind_final(2,jj)/b)+1, ind_final(1,jj)/a+1) = ...
% c(ind(2,jj)/br+1, ind(1,jj)/ar+1);
% end
for w=0:W-1
c(floor(ind_final(2,:)/b)+1+(ind_final(1,:)/a)*M+w*M*N) = ...
c_rect(ind(2,:)/br+1+(ind(1,:)/ar)*Mr+w*M*N);
end;



37 changes: 10 additions & 27 deletions comp/gabpars_from_windowsignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,30 @@
callfun=stacknames(2).name;
end;

% ----- step 1 : Verify a, M ----------
assert_squarelat(a,M,1,callfun,0);

% ----- step 2 : Verify f and determine its length -------
% ----- step 1 : Verify f and determine its length -------
% Change f to correct shape.
[f,Ls,W,wasrow,remembershape]=comp_sigreshape_pre(f,callfun,0);

% ----- step 3 : Determine L
if ~isempty(L)
if (prod(size(L))~=1 || ~isnumeric(L))
error('%s: L must be a scalar',callfun);
end;

if rem(L,1)~=0
error('%s: L must be an integer',callfun);
end;

if rem(L,M)~=0
error('%s: The length of the transform must be divisable by M = %i',...
callfun,M);
end;
if isempty(L)

if rem(L,a)~=0
error('%s: The length of the transform must be divisable by a = %i',...
callfun,a);
end;
% ----- step 2b : Verify a, M and get L from the signal length f----------
L=dgtlength(Ls,a,M);

else

% Smallest length transform.
Lsmallest=lcm(a,M);
% ----- step 2a : Verify a, M and get L
Luser=dgtlength(L,a,M);
if Luser~=L
error('Incorrect transform length specified.');
end;

% Choose a transform length larger than both the length of the
% signal and the window.
L=ceil(Ls/Lsmallest)*Lsmallest;
end;

b=L/M;
N=L/a;

% ----- step 4 : Determine the window
% ----- step 3 : Determine the window

[g,info]=gabwin(g,a,M,L,callfun);

Expand Down
4 changes: 2 additions & 2 deletions comp/nonsepgabpars_from_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
if isnumeric(g)
L=length(g);
else
L=nonsepdgtlengthsignal(1,a,M,lt);
L=dgtlength(1,a,M,lt);
end;
else
Lcheck=nonsepdgtlengthsignal(L,a,M,lt);
Lcheck=dgtlength(L,a,M,lt);
if Lcheck~=L
error('%s: Invalid transform size L',upper(mfilename));
end;
Expand Down
2 changes: 1 addition & 1 deletion filterbank/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% UFILTERBANK - Uniform Filter bank
% IFILTERBANK - Inverse normal/uniform filter bank
% FILTERBANKWIN - Evaluate filterbank window
% FILTERBANKLENGTHSIGNAL - Length of filterbank to expand signal
% FILTERBANKLENGTH - Length of filterbank to expand signal
% FILTERBANKLENGTHCOEF - Length of filterbank to expand coefficients
%
% Window construction and bounds
Expand Down
2 changes: 1 addition & 1 deletion filterbank/filterbank.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end;

if isempty(L)
L=filterbanklengthsignal(Ls,a);
L=filterbanklength(Ls,a);
end;

[g,info]=filterbankwin(g,a,L,'normal');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function L=filterbanklengthsignal(Ls,a);
%FILTERBANKLENGTHSIGNAL Filterbank length from signal
% Usage: L=filterbanklengthsignal(Ls,a);
function L=filterbanklength(Ls,a);
%FILTERBANKLENGTH Filterbank length from signal
% Usage: L=filterbanklength(Ls,a);
%
% `filterbanklengthsignal(Ls,a)` returns the length of a filterbank with
% `filterbanklength(Ls,a)` returns the length of a filterbank with
% time shifts *a*, such that it is long enough to expand a signal of
% length *Ls*.
%
Expand Down
4 changes: 2 additions & 2 deletions filterbank/filterbanklengthcoef.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
% time-shifts *a*, such that the filterbank is long enough to expand the
% coefficients *coef*.
%
% If instead a signal is given, call |filterbanklengthsignal|_.
% If instead a signal is given, call |filterbanklength|_.
%
% See also: filterbank, filterbanklengthsignal
% See also: filterbank, filterbanklength

if iscell(coef)
Mcoef=numel(coef);
Expand Down
2 changes: 1 addition & 1 deletion filterbank/ufilterbank.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
a=a(1);

if isempty(L)
L=filterbanklengthsignal(Ls,a);
L=filterbanklength(Ls,a);
end;

[g,info]=filterbankwin(g,a,L,'normal');
Expand Down
1 change: 1 addition & 0 deletions fourier/magresp.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
end;

plot(xrange,FF,kv.opts{:});
set(gca,'yscale','linear');
axis(axisvec);
ylabel('Magnitude response (dB)');

Expand Down
2 changes: 1 addition & 1 deletion fourier/pgauss.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
% the window giving the smallest frame bound ratio is generated by
% `pgauss(L,a*M/L)`.
%
% See also: longpar, psech, firwin, pbspline, normalize
% See also: dgtlength, psech, firwin, pbspline, normalize
%
% Demos: demo_pgauss
%
Expand Down
2 changes: 1 addition & 1 deletion frames/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% FRAMERED - Redundancy of frame
% FRANAMAT - Frame analysis operator matrix
% FRSYNMAT - Frame synthesis operator matrix
% FRAMELENGTHSIGNAL - Length of frame to expand signal
% FRAMELENGTH - Length of frame to expand signal
% FRAMELENGTHCOEF - Length of frame given a set of coefficients
%
% Coefficients conversions
Expand Down
4 changes: 2 additions & 2 deletions frames/frameaccel.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
% If `frameaccel` is called twice for the same transform length, no
% additional computations will be done.
%
% See also: newframe, frana, framelengthsignal, framelengthcoef
% See also: newframe, frana, framelength, framelengthcoef

if ~isfield(F,'ga')
% Quick exit, the transform does not use analysis nor synthesis
Expand All @@ -25,7 +25,7 @@

% From this point and on, we are sure that F.ga and F.gs exists.

L=framelengthsignal(F,Ls);
L=framelength(F,Ls);

if (isfield(F,'L') && (L==F.L))
% Quick return, we have already accelerated
Expand Down
2 changes: 1 addition & 1 deletion frames/framegrouplasso.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

[flags,kv]=ltfatarghelper({'C','tol','maxit'},definput,varargin);

L=framelengthsignal(F,length(x));
L=framelength(F,length(x));

F=frameaccel(F,L);

Expand Down
2 changes: 1 addition & 1 deletion frames/framelasso.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
% basis coefficients (BCR algorithm)

% Determine transform length, and calculate the window.
L = framelengthsignal(F,size(x,1));
L = framelength(F,size(x,1));

% Accelerate frame, we will need it repeatedly
F=frameaccel(F,L);
Expand Down
12 changes: 6 additions & 6 deletions frames/framelengthsignal.m → frames/framelength.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function L=framelengthsignal(F,Ls);
%FRAMELENGTHSIGNAL Frame length from signal
% Usage: L=framelengthsignal(F,Ls);
function L=framelength(F,Ls);
%FRAMELENGTH Frame length from signal
% Usage: L=framelength(F,Ls);
%
% `framelengthsignal(F,Ls)` returns the length of the frame *F*, such that
% `framelength(F,Ls)` returns the length of the frame *F*, such that
% *F* is long enough to expand a signal of length *Ls*.
%
% If the frame length is longer than the signal length, the signal will be
Expand All @@ -17,11 +17,11 @@

switch(F.type)
case {'dgt','dgtreal'}
L = longpar('dgt',Ls,F.a,F.M);
L = dgtlength(Ls,F.a,F.M);
case {'dwilt','wmdct'}
L = longpar('dwilt',Ls,F.M);
case {'gen'}
L = size(F.ga,1);
case {'filterbank','ufilterbank','filterbankreal','ufilterbankreal'}
L = filterbanklengthsignal(Ls,F.a);
L = filterbanklength(Ls,F.a);
end;
4 changes: 2 additions & 2 deletions frames/framelengthcoef.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
% `framelengthcoef(F,Ncoef)` returns the length of the frame *F*, such that
% *F* is long enough to expand the coefficients of length *Ncoef*.
%
% If instead a signal is given, call |framelengthsignal|_.
% If instead a signal is given, call |framelength|_.
%
% See also: newframe, framelengthsignal
% See also: newframe, framelength

if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
Expand Down
2 changes: 1 addition & 1 deletion frames/franamat.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
error('%s: The analysis operator of this frame does not have a matrix representation.',upper(mfilename));
otherwise

Lcheck=framelengthsignal(F,L);
Lcheck=framelength(F,L);
if Lcheck~=L
error('%s: Incompatible frame length.',upper(mfilename));
end;
Expand Down
2 changes: 1 addition & 1 deletion frames/frsynmat.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
error('%s: The synthesis operator of this frame does not have a matrix representation.',upper(mfilename));
otherwise

Lcheck=framelengthsignal(F,L);
Lcheck=framelength(F,L);
if Lcheck~=L
error('%s: Incompatible frame length.',upper(mfilename));
end;
Expand Down
5 changes: 3 additions & 2 deletions frames/newframe.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
% signals with analysis window *ga*, synthesis window *gs*,time-shift *a*
% and *M* channels. See the help on |dgtreal|_ for more information.
%
% `newframe('dwilt',ga,gs,M)` constructs a Wilson basis with analysis window
% *ga*, synthesis window *gs*, and *M* channels. See the help on |dwilt|_ for more information.
% `newframe('dwilt',ga,gs,M)` constructs a Wilson basis with analysis
% window *ga*, synthesis window *gs*, and *M* channels. See the help on
% |dwilt|_ for more information.
%
% `newframe('wmdct',ga,gs,M)` constructs a windowed MDCT basis with
% analysis window *ga*, synthesis window *gs*, and *M* channels. See the
Expand Down
2 changes: 1 addition & 1 deletion gabor/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
% DGTREAL - DGT for real-valued signals.
% IDGTREAL - IDGT for real-valued signals.
% GABWIN - Evaluate Gabor window.
% LONGPAR - Easy calculation of LONG parameters.
% DGTLENGTH - Length of Gabor system to expand a signal
%
% Wilson bases and WMDCT
% DWILT - Discrete Wilson transform.
Expand Down
Loading

0 comments on commit b73adea

Please sign in to comment.