function eval_blit2()
L = 64000;
Nb = 65;
Nos = 8;
fs = 48000;
fstart = 440;
fend = 1760;
df = (fend-fstart)/L
fcut = 16000;

x = (0:Nb*Nos-1) - (Nb*Nos-1)/2;
H = sinc(2*fcut/fs.*x/Nos).*kaiser(Nos*Nb, 8)';
for ii=0:Nos-1,
    for jj=0:Nb-1
        Hs(ii+1,jj+1) = H(Nos-ii+Nos*jj);
    end
end;

%Hs = init_steps(Nb, Nos);

f = fstart;
k = 1./sum(Hs')
%k = ones(1, Nb);
y0 = 0;
y1 = 0;
y2 = .5;
ks = 0.002*f/55
ii = 0;
ff = 0;
nn = 1;
jj = Nb;
kk = 1;
for i = 1:L,
	P = fs/f;
	Pi = floor(P);
	Pf = fix(Nos*(fs/f - Pi));
	
    if ii == 0
        jj = 1;
        kk = ff + 1;
        ii = Pi;
        ff = ff + Pf;
        if ff > (Nos-1)
            ff = ff - Nos;
            ii = ii + 1;
        end
    end;
    ii = ii - 1;
    if jj <= Nb
        y0 = k(kk)*Hs(kk,jj); % - ks*y0;
        jj = jj + 1;
    end;
    y0 = y0 - ks*y0;
    y1 = 1 - y0;
    y2 = 0.001*y1 + 0.999*y2;
    blit(nn) = y1-y2;			% DC removal
    nn = nn + 1;
	f = f + df;
    
end;
wavwrite(0.7*blit, fs, 'blit.wav');

for ii = 1:Nos
    step(ii,:) = k(ii).*filter(Hs(ii,:), 1, [ones(1,Nb)]);
end

DC = y2

close all
plot(H); grid;

figure
plot(1:length(blit), blit, '-o'); grid;

figure
plot(abs(fft(blit))); grid;

figure
plot(step', '-'); grid;

figure
plot(Hs(1,:)', '-+'); grid;

function steps = init_steps(step_width, phase_count)

low_pass  = 0.999; % lower values filter more high frequency
high_pass = 0.990; % lower values filter more low frequency

%phase_count = 32; % number of phase offsets to sample band-limited step at
%step_width  = 16; % number of samples in each final band-limited step

%steps [phase_count] [step_width]; // would use short for speed in a real program

	% Generate master band-limited step by adding sine components of a square wave
	master_size = step_width * phase_count;
	% master [master_size]; // large; might want to malloc() instead
	for i = 0:master_size-1
		master(i+1) = 0.5;
    end;
    
    gain = 0.5 / 0.777; % adjust normal square wave's amplitude of ~0.777 to 0.5
	sine_size = 256 * phase_count + 2;
	max_harmonic = sine_size / 2 / phase_count;
	for h = 1:2:max_harmonic
		amplitude = gain / h;
		to_angle = 3.14159265358979323846 * 2 / sine_size * h;
    	for i = 0:master_size-1
			master(i+1) = master(i+1) + sin( (i - master_size / 2) * to_angle ) * amplitude;
        end
		gain = gain * low_pass;
    end
	
	% Sample master step at several phases
	for phase = 0:phase_count-1
		error = 1.0;
		prev = 0.0;
    	for i = 0:step_width-1
			cur = master (i * phase_count + (phase_count - 1 - phase)+1);
			delta = cur - prev;
			error = error - delta;
			prev = cur;
			steps (phase+1, i+1) = delta;
        end
		
		% each delta should total 1.0
		steps (phase+1, step_width / 2) = steps (phase+1, step_width / 2) + error * 0.5;
		steps (phase+1, step_width / 2 + 1) = steps (phase+1, step_width / 2 + 1) + error * 0.5;
    end
