I have found C implementation for remez exchange algorithm(https://github.com/janovetz/remez-exchange/blob/master/remez.c) and I want to use this to implement a generic prototype lowpass filter. Although the comments have been provided to guide on how to use it I am having trouble implementing it. Could anyone tell me what are the correct inputs which I am suppose to give to the remez() function to get coefficients for lowpass filter because I suspect I am not providing the correct inputs.
EDIT: I have been reading and experimenting with the code and I found out that for lowpass filter I should give type as 1(i.e Bandpass). Anyhow just to try the code I gave the parameters for bandpass filter in MATLAB and same parameters to remez() but the results are very different. Could somebody have a look at my coefficients and tell me what I am doing wrong because I don't get it?
% All frequency values are in Hz. Fs = 2000; % Sampling Frequency Fstop1 = 200; % First Stopband Frequency Fpass1 = 300; % First Passband Frequency Fpass2 = 700; % Second Passband Frequency Fstop2 = 800; % Second Stopband Frequency Dstop1 = 0.000177827941; % First Stopband Attenuation Dpass = 0.0057563991496; % Passband Ripple Dstop2 = 0.000177827941; % Second Stopband Attenuation dens = 20; % Density Factor % Calculate the order from the parameters using FIRPMORD. [N, Fo, Ao, W] = firpmord([Fstop1 Fpass1 Fpass2 Fstop2]/(Fs/2), [0 1 ... 0], [Dstop1 Dpass Dstop2]);
These values (N, Fo, Ao, W) obtained from MATLAB, I feed to remez() function.
So the C++ function looks like: (just the part where I am calling the remez function)
int numtaps = 64; int numbands = 3; std::vector<double> h(numtaps); double bands = [0, 0.2000, 0.3000, 0.7000, 0.8000, 1.000]; double des = [0, 0, 1, 1, 0, 0]; double weight = [0.000177827941, 0.0057563991496, 0.000177827941]; int type = 1; int griddensity = 20; remez(&(h), int *numtaps, int *numband, const double bands, const double des, const double weight, int *type, int *griddensity);