1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use num::Float;
use thiserror::Error;

moddef::moddef!(
    flat(pub) mod {
        besselap,
        besself,
        buttap,
        butter,
        buttord,
        cheb1ap,
        cheb1ord,
        cheb2ap,
        cheb2ord,
        cheby1,
        cheby2,
        ellip,
        ellipap,
        ellipord,
        fir1,
        fir2,
        firgr,
        firls,
        firpm,
        firpmord,
        gammatone_fir,
        gammatone_iir,
        iir_comb,
        iir_design,
        iir_notch,
        iir_peak,
        kaiserord,
        pei_tseng_notch,
        qp_kaiser,
        sgolay
    }
);

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FilterGenType
{
    LowPass,
    HighPass,
    BandPass,
    BandStop
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FilterClassType
{
    Symmetric,
    Antisymmetric,
    Differentiator
}

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum FilterGenPlane<T>
where
    T: Float
{
    S,
    Z {
        sampling_frequency: Option<T>
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Error)]
pub enum FilterGenError
{
    #[error("Filter order must be at least 1.")]
    ZeroOrder,
    #[error("Frequencies must be monotonic starting at zero.")]
    FrequenciesNotNondecreasing,
    #[error("Frequencies must be positive, and if the filter is digital; less than 1/2 the sampling frequency, or if no sampling frequency is specified, between 0 and 1.")]
    FrequenciesOutOfRange,
    #[error("List of frequencies and list of magnitudes must have equal length.")]
    FrequenciesAndMagnitudesDifferentLength,
}

#[derive(Debug, Clone, Copy, PartialEq, Error)]
pub enum FilterBandError
{
    #[error("Bands must be monotonic starting at zero.")]
    EdgesNotNondecreasing,
    #[error("Band edges must be less than 1/2 the sampling frequency, or if no sampling frequency is specified, between 0 and 1.")]
    EdgesOutOfRange,
    #[error("Sampling frequency must be a positive number.")]
    InvalidSamplingFrequency,
    #[error("One band must surround the other.")]
    BandNotSurrounding,
}