public static Filters.FIRFilter DesignFIR1(int h_len, float[] bands, float[] responses, float[] weights , FIR_PM_WeightingType[] wTypes, FIR_PM_BandType bType) { //firdespm_run(_h_len, _num_bands, * _bands, * _des, * _weights, //Filters.FIR_PM_WeightingType* _wtype, Filters.FIR_PM_BandType _btype, float* _h); float[] h = new float[h_len]; if (bands.Length % 2 != 0) { throw new Exception("argument `bands` must be of even length"); } libliquid.firdespm_custom(h_len, bands.Length / 2, bands, responses, weights, wTypes, bType, h); FIRFilter f = new FIRFilter(h); return(f); }
public static Dictionary <float, ComplexTypes.Complex> FrequencyResponse(FIRFilter filt, int Length = 512) { Dictionary <float, ComplexTypes.Complex> retval = new Dictionary <float, ComplexTypes.Complex>(); float[] f = new float[Length]; unsafe { libliquid.Complex *res = stackalloc libliquid.Complex[Length]; libliquid.fir_response(filt.Coefficients, filt.Coefficients.Length, f, res, Length); for (int i = 0; i < Length; i++) { retval.Add(f[i], libliquid.ToOSLComplex(res[i])); } } return(retval); }