clear;

fs = 44100;

fc = 1/8;
order = 2;
nfilt = 256;

fsaw = 1/64;
nsaw = floor(fs * 0.5 * fsaw) / fsaw;

% standard and oversampled filter responses
x = impulse(nfilt);
y1 = butter_over(order, fc, 1, x);
y2 = butter_over(order, fc, 2, x);

y2 = y2 * sum(y1)/sum(y2);		% fix up normalization

% apply them to a bandlimited saw
saw = oscsawbl(fsaw, nsaw);
if 1
	filt1 = cancel_DC(filter(y1, [1], saw));  filt1 = filt1(2/fsaw : end);
	filt2 = cancel_DC(filter(y2, [1], saw));  filt2 = filt2(2/fsaw : end);
end

if 0
	clf;
	hold on;

	octaves = 8;
	plotoct(filt1, [1], octaves, 'w-');
	plotoct(filt2, [1], octaves, 'r-');

	hold off;
	shg;	
elseif 1
	clf;
	hold on;

	t = 1:nfilt;
	octaves = 8;
	plotoct(y1, [1], octaves, 'w-');
	plotoct(y2, [1], octaves, 'r-');

	axis([-octaves 0 -100 0]);
	hold off;
	shg;
end;
