spLib
読み取り中…
検索中…
一致する文字列を見つけられません
filter.h
[詳解]
1
4#ifndef SPLIB_FILTER_H
5#define SPLIB_FILTER_H
6
7#include <sp/vector.h>
8#include <sp/fft.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#if defined(MACOS)
15#pragma import on
16#endif
17
25 /*----@addtogroup filterGroup----*/
26
30extern void fvunwrap(spFVector phs, float cutoff);
31extern void dvunwrap(spDVector phs, double cutoff);
32extern float sincf(float x);
33extern double sinc(double x);
34extern float sinccf(float x, float c);
35extern double sincc(double x, double c);
36
42extern spDVector xdvbandstop(double lp_cutoff, double hp_cutoff, double sidelobe, double trans, double gain);
43extern spDVector xdvbandpass(double hp_cutoff, double lp_cutoff, double sidelobe, double trans, double gain);
44extern spDVector xdvlowpass(double cutoff, double sidelobe, double trans, double gain);
45extern spDVector xdvhighpass(double cutoff, double sidelobe, double trans, double gain);
46
52extern spDVector xdvfftfiltex(spFFTRec fftrec, spDVector b, spDVector x);
53extern spDVector xdvfftfiltmex(spFFTRec fftrec, spDVector b, spDVector x);
54extern spDVector xdvfftfilt(spDVector b, spDVector x, long fftl);
55extern spDVector xdvfftfiltm(spDVector b, spDVector x, long fftl);
56extern spDVector xdvconv(spDVector a, spDVector b);
57
58/* length of z must be larger than MAX(length of b, length of a)-1 */
59extern spDVector xdvinitfilterstates(spDVector b, spDVector a); /* 0.9.1+ */
60extern void dvfiltersamplecplx(spDVector b, spDVector a, spDVector z, double *re, double *im);
61extern double filtersample(double *b, long blen, double *a, long alen, double *z, long zlen, double x);
62extern double dvfiltersample(spDVector b, spDVector a, spDVector z, double x);
63extern spDVector xdvfilterex(spDVector b, spDVector a, spDVector z, spDVector x);
64extern spDVector xdvfilter(spDVector b, spDVector a, spDVector x);
65
66extern spDVector xdvfreqzex(spFFTRec fftrec, spDVector b /* can be NODATA */, spDVector a /* can be NODATA */);
67extern spDVector xdvfreqz(spDVector b /* can be NODATA */, spDVector a /* can be NODATA */, long fftl /* can be 0 (auto select) */);
68
74/* linear interpolation (X must be monotonically increasing) */
75extern spBool dvinterp1l(spDVector x, spDVector y, spDVector xi, spDVector yi);
76extern spDVector xdvinterp1l(spDVector x, spDVector y, spDVector xi);
77
78/* nearest neighbor interpolation (X must be monotonically increasing) */
79extern spBool dvinterp1n(spDVector x, spDVector y, spDVector xi, spDVector yi);
80extern spDVector xdvinterp1n(spDVector x, spDVector y, spDVector xi);
81
82/* cubic spline interpolation on not-a-knot condition (X must be monotonically increasing) */
83extern spBool dvinterp1s(spDVector x, spDVector y, spDVector xi, spDVector yi);
84extern spDVector xdvinterp1s(spDVector x, spDVector y, spDVector xi);
85
86/* Resample data at a higher rate using lowpass interpolation */
87extern spDVector xdvinterpex(spDVector x, long r, long l, double a);
88extern spDVector xdvinterp(spDVector x, long r); /* l = 4, a = 0.5 */
89
90/* clamped cubic spline interpolation */
91extern spBool dvsplinecl(spDVector x, spDVector y, spDVector xi, spDVector yi, double leftslope, double rightslope);
92extern spDVector xdvsplinecl(spDVector x, spDVector y, spDVector xi, double leftslope, double rightslope);
93/* cubic spline.
94 * if notaknot == SP_TRUE, not-a-knot condition (same as MATLAB), otherwise natural condition. */
95extern spBool dvspline(spDVector x, spDVector y, spDVector xi, spDVector yi, spBool notaknot);
96extern spDVector xdvspline(spDVector x, spDVector y, spDVector xi, spBool notaknot);
97
98#define SP_DECIMATE_OPTION_USE_FIR (1<<0)
99#define SP_DECIMATE_OPTION_KEEP_EDGE (2<<0)
100#define SP_DECIMATE_OPTION_NO_FILTFILT (3<<0)
101
102/* decrease the sampling rate for a sequence (decimation) */
103extern spDVector xdvdecimateex(spDVector x,
104 long r,
105 long order, /* 0: use default (chebyshev: 8, FIR: 30) */
106 unsigned long options);
107extern spDVector xdvdecimate(spDVector x, long r); /* use 8-order chebyshev IIR */
108
109typedef struct _spDecimateRec *spDecimateRec;
110extern spDecimateRec spDecimateOpen(long r,
111 long order, /* 0: use default (chebyshev: 8, FIR: 30) */
112 long max_input_buf_length,
113 unsigned long options,
114 long *max_output_buf_length,
115 long *default_delay); /* *default_delay = -1: cannot calculate delay */
116extern spBool spDecimateClose(spDecimateRec decimate);
117extern long spDecimateProcess(spDecimateRec decimate, double *input_buf, long input_buf_length, double *output_buf,
118 spBool last_frame, long *current_delay); /* *current_delay = -1: cannot calculate delay */
119
125/* Lowpass FIR digital filter by using specified window */
126extern void dvfir1win(spDVector filter, /* (i/o) input is window, output is filter */
127 double cutoff); /* cut-off frequency */
128extern spDVector xdvfir1win(spDVector win,
129 double cutoff); /* cut-off frequency */
130
131/* Lowpass FIR digital filter by using Hamming window */
132extern spDVector xdvfir1(long order, /* return [order + 1] */
133 double cutoff); /* cut-off frequency */
134
135/* Bandpass FIR Filter (startf-endf) by using specified window */
136extern spBool dvfir1bpwin(spDVector filter, /* (i/o) input is window, output is filter */
137 double startf,
138 double endf);
139extern spDVector xdvfir1bpwin(spDVector win,
140 double startf,
141 double endf);
142
143/* Bandpass FIR Filter (startf-endf) by using Hamming window */
144extern spDVector xdvfir1bp(long order,
145 double startf,
146 double endf);
147
148/* Bandstop FIR Filter (startf-endf) by using specified window */
149extern spBool dvfir1bswin(spDVector filter, /* (i/o) input is window, output is filter */
150 double startf,
151 double endf);
152extern spDVector xdvfir1bswin(spDVector win,
153 double startf,
154 double endf);
155
156/* Bandstop FIR Filter (startf-endf) by using Hamming window */
157extern spDVector xdvfir1bs(long order, /* return [odd length] */
158 double startf,
159 double endf);
160
161/* Highpass FIR digital filter by using specified window */
162extern void dvfir1hpwin(spDVector filter, /* (i/o) input is window, output is filter */
163 double cutoff); /* cut-off frequency */
164extern spDVector xdvfir1hpwin(spDVector win,
165 double cutoff); /* cut-off frequency */
166
167/* Highpass FIR digital filter by using Hamming window */
168extern spDVector xdvfir1hp(long order, /* return [odd length] */
169 double cutoff); /* cut-off frequency */
170
176/* Zero-phase forward and reverse digital filtering */
177extern spDVector xdvfiltfiltex(spDVector b, /* filter-coefficient (numerator) */
178 spDVector a, /* filter-coefficient (denominator) */
179 spDVector x, /* input data */
180 spBool use_optimum_state); /* SP_TRUE if optimum initial states are used */
181extern spDVector xdvfiltfilt(spDVector b, /* filter-coefficient (numerator) */
182 spDVector a, /* filter-coefficient (denominator) */
183 spDVector x); /* input data */
184
190/* Bilinear transformation for filter (analog -> digital) */
191extern spDVectors xdvsbilinear(spDVector pv, /* pole */
192 double gain, /* gain */
193 double cutoff, /* cutoff frequency */
194 spBool hp_flag); /* highpass filter */
195
196/* Chebyshev analog lowpass filter prototype */
197extern spDVector xdvcheb1ap(long n, /* order */
198 double rp, /* passband ripple [dB] */
199 double *gain);/* gain */
200
201/* Chebyshev digital and analog filter design */
202extern spDVectors xdvscheby1(long n, /* order */
203 double rp, /* passband ripple [dB] */
204 double cutoff, /* cut-off frequency */
205 spBool hp_flag); /* highpass filter */
206
207/* Butterworth analog lowpass filter prototype (gain = 1.0) */
208extern spDVector xdvbuttap(long n); /* order */
209extern spDVectors xdvsbutter(long n, /* order */
210 double cutoff, /* cut-off frequency */
211 spBool hp_flag); /* highpass filter */
212
215 /*----@addtogroup windowGroup----*/
216
217#if defined(MACOS)
218#pragma import off
219#endif
220
221#ifdef __cplusplus
222} /* Close scope of 'extern "C"' declaration */
223#endif
224
225#endif /* SPLIB_FILTER_H */
FFTの実行を制御するクラスです.
int spBool
double型を扱うためのベクトル型です.
Definition vector.h:248
float型を扱うためのベクトル型です.
Definition vector.h:214