1use ffi::SwrDitherType::*;
2use ffi::*;
3
4#[derive(Eq, PartialEq, Copy, Clone, Debug)]
5pub enum Dither {
6 None,
7 Rectangular,
8 Triangular,
9 TriangularHighPass,
10
11 NoiseShapingLipshitz,
12 NoiseShapingFWeighted,
13 NoiseShapingModifiedEWeighted,
14 NoiseShapingImprovedEWeighted,
15 NoiseShapingShibata,
16 NoiseShapingLowShibata,
17 NoiseShapingHighShibata,
18}
19
20impl From<SwrDitherType> for Dither {
21 fn from(value: SwrDitherType) -> Dither {
22 match value {
23 SWR_DITHER_NONE => Dither::None,
24 SWR_DITHER_RECTANGULAR => Dither::Rectangular,
25 SWR_DITHER_TRIANGULAR => Dither::Triangular,
26 SWR_DITHER_TRIANGULAR_HIGHPASS => Dither::TriangularHighPass,
27
28 SWR_DITHER_NS => Dither::None,
29 SWR_DITHER_NS_LIPSHITZ => Dither::NoiseShapingLipshitz,
30 SWR_DITHER_NS_F_WEIGHTED => Dither::NoiseShapingFWeighted,
31 SWR_DITHER_NS_MODIFIED_E_WEIGHTED => Dither::NoiseShapingModifiedEWeighted,
32 SWR_DITHER_NS_IMPROVED_E_WEIGHTED => Dither::NoiseShapingImprovedEWeighted,
33 SWR_DITHER_NS_SHIBATA => Dither::NoiseShapingShibata,
34 SWR_DITHER_NS_LOW_SHIBATA => Dither::NoiseShapingLowShibata,
35 SWR_DITHER_NS_HIGH_SHIBATA => Dither::NoiseShapingHighShibata,
36 SWR_DITHER_NB => Dither::None,
37 }
38 }
39}
40
41impl From<Dither> for SwrDitherType {
42 fn from(value: Dither) -> SwrDitherType {
43 match value {
44 Dither::None => SWR_DITHER_NONE,
45 Dither::Rectangular => SWR_DITHER_RECTANGULAR,
46 Dither::Triangular => SWR_DITHER_TRIANGULAR,
47 Dither::TriangularHighPass => SWR_DITHER_TRIANGULAR_HIGHPASS,
48
49 Dither::NoiseShapingLipshitz => SWR_DITHER_NS_LIPSHITZ,
50 Dither::NoiseShapingFWeighted => SWR_DITHER_NS_F_WEIGHTED,
51 Dither::NoiseShapingModifiedEWeighted => SWR_DITHER_NS_MODIFIED_E_WEIGHTED,
52 Dither::NoiseShapingImprovedEWeighted => SWR_DITHER_NS_IMPROVED_E_WEIGHTED,
53 Dither::NoiseShapingShibata => SWR_DITHER_NS_SHIBATA,
54 Dither::NoiseShapingLowShibata => SWR_DITHER_NS_LOW_SHIBATA,
55 Dither::NoiseShapingHighShibata => SWR_DITHER_NS_HIGH_SHIBATA,
56 }
57 }
58}
59