File indexing completed on 2024-05-12 03:47:51

0001 /*
0002     File                 : nsl_filter.h
0003     Project              : LabPlot
0004     Description          : NSL Fourier filter functions
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2016 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef NSL_FILTER_H
0011 #define NSL_FILTER_H
0012 
0013 #include <stdlib.h>
0014 
0015 #define NSL_FILTER_TYPE_COUNT 4
0016 typedef enum {
0017     nsl_filter_type_low_pass,
0018     nsl_filter_type_high_pass,
0019     nsl_filter_type_band_pass,
0020     nsl_filter_type_band_reject
0021 } nsl_filter_type; /*TODO: Threshold */
0022 extern const char* nsl_filter_type_name[];
0023 #define NSL_FILTER_FORM_COUNT 6
0024 typedef enum {
0025     nsl_filter_form_ideal,
0026     nsl_filter_form_butterworth,
0027     nsl_filter_form_chebyshev_i,
0028     nsl_filter_form_chebyshev_ii,
0029     nsl_filter_form_legendre,
0030     nsl_filter_form_bessel
0031 } nsl_filter_form;
0032 extern const char* nsl_filter_form_name[];
0033 /* unit for cutoff
0034 Frequency=0..f_max, Fraction=0..1, Index=0..N-1
0035 */
0036 #define NSL_FILTER_CUTOFF_UNIT_COUNT 3
0037 typedef enum { nsl_filter_cutoff_unit_frequency, nsl_filter_cutoff_unit_fraction, nsl_filter_cutoff_unit_index } nsl_filter_cutoff_unit;
0038 extern const char* nsl_filter_cutoff_unit_name[];
0039 
0040 /* Gain G(x) for Bessel filter */
0041 double nsl_filter_gain_bessel(int n, double x);
0042 
0043 int nsl_filter_apply(double data[], size_t n, nsl_filter_type type, nsl_filter_form form, int order, double cutindex, double bandwidth);
0044 int nsl_filter_fourier(double data[], size_t n, nsl_filter_type type, nsl_filter_form form, int order, int cutindex, int bandwidth);
0045 
0046 #endif /* NSL_FILTER_H */