function c = makecomb(freq, length, width, fs, target_mean, center_strength)

% c = makecomb(freq, length, width, fs)
% frequency is specified in beats per minute
% length in millisecond
% width in milliseconds to one side of center
% fs in samples per second
% depth is how low it drops in the combs
% c is the comb filter

if(nargin < 5)
    target_mean = .8;
end
if(nargin < 6)
    center_strength = 1;
end

f = fs / (freq / 60);           % samples per cycle
l = round(fs * length / 1000);  % cycles to average over
w = fs * width / 1000;          % cycles width of window for pulse

i = -l:l;
c = 1 - (((abs(mod(i, f)) <= w)) | (abs(mod(i,f) >= (f-w)))) - center_strength*(abs(i)<= w);
scale = (-1+target_mean)/(mean(c)-1);
c = scale*c-(scale-1);