% takes input x or reads in from file filename and runs filter banks % start and stop define the range of samples to analyze function [xr, totalBits] = filterBanks8(x, filename, start, stop, h, g, Fs, bits, f, thres, FFTLength, totalBits, quantType) % set number of filters M = 32; % set filter length; L = 2*M; convLength = L + length(x) - 1; v = zeros(M,convLength); y = zeros(M,floor(length(v)/M)); wo = zeros(M,M*length(y)); xr = zeros(1,L + M*length(y) - 1); % for each filter... for k = 1:M k % calculate outputs of filter bank v(k,:) = conv(h(k,:),x); % decimate outputs by M for n = 1:floor(convLength/M) y(k,n) = v(k,M*n); end % quantize the signal according to the psychoacoustic model [y(k,:), totalBits] = performEncoding(y(k,:), Fs, bits, FFTLength, M, f, k, thres, totalBits, quantType); % upsample outputs for n = 1:convLength if (mod(n,M) == 0) wo(k,n) = y(k,ceil(n/M)); end end % reconstruct original signal from synthesis filters temp = conv(g(k,:),wo(k,:)); lTemp = length(temp); xr(1,1:lTemp) = xr(1,1:lTemp) + temp; end % remove excessive zeros epsilon = 0.01; z = find(xr(1:length(xr)/2 > epsilon)); s = min(z); if (isempty(s)) s = 1; end e = s + FFTLength - 1; if (e > length(xr)) e = length(xr); end xr = xr(s:e);