/usr/share/octave/packages/signal-1.3.0/qp_kaiser.m is in octave-signal 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | ## Copyright (C) 2002 André Carezia <andre@carezia.eng.br>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} qp_kaiser (@var{nb}, @var{at})
## @deftypefnx {Function File} {} qp_kaiser (@var{nb}, @var{at}, @var{linear})
##
## Computes a finite impulse response (FIR) filter for use with a
## quasi-perfect reconstruction polyphase-network filter bank. This
## version utilizes a Kaiser window to shape the frequency response of
## the designed filter. Tha number nb of bands and the desired
## attenuation at in the stop-band are given as parameters.
##
## The Kaiser window is multiplied by the ideal impulse response
## h(n)=a.sinc(a.n) and converted to its minimum-phase version by means
## of a Hilbert transform.
##
## By using a third non-null argument, the minimum-phase calculation is
## ommited at all.
## @end deftypefn
function h = qp_kaiser (nb, at, linear = 0)
if (nargin < 2)
print_usage;
elseif !(isscalar (nb) && (nb == round(nb)) && (nb >= 0))
error ("qp_kaiser: nb has to be a positive integer");
elseif !(isscalar (at) && (at == real (at)))
error ("qp_kaiser: at has to be a real constant");
endif
## Bandwidth
bandwidth = pi/nb;
## Attenuation correction (empirically
## determined by M. Gerken
## <mgk@lcs.poli.usp.br>)
corr = (1.4+0.6*(at-20)/80)^(20/at);
at = corr * at;
## size of window (rounded to next odd
## integer)
N = (at - 8) / (2.285*bandwidth);
M = fix(N/2);
N = 2*M + 1;
## Kaiser window
if (at>50)
beta = 0.1102 * (at - 8.7);
elseif (at>21)
beta = 0.5842 * (at - 21)^0.4 + 0.07886 * (at - 21);
else
beta = 0;
endif
w = kaiser(N,beta);
## squared in freq. domain
wsquared = conv(w,w);
## multiplied by ideal lowpass filter
n = -(N-1):(N-1);
hideal = 1/nb * sinc(n/nb);
hcomp = wsquared .* hideal;
## extract square-root of response and
## compute minimum-phase version
Ndft = 2^15;
Hsqr = sqrt(abs(fft(hcomp,Ndft)));
if (linear)
h = real(ifft(Hsqr));
h = h(2:N);
h = [fliplr(h) h(1) h];
else
Hmin = Hsqr .* exp(-j*imag(hilbert(log(Hsqr))));
h = real(ifft(Hmin));
h = h(1:N);
endif
## truncate and fix amplitude scale
## (H(0)=1)
h = h / sum(h);
endfunction
|