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
use crate::{ffi, Status, Synth};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
pub enum InterpMethod {
None = ffi::fluid_interp_FLUID_INTERP_NONE as _,
Linear = ffi::fluid_interp_FLUID_INTERP_LINEAR as _,
FourthOrder = ffi::fluid_interp_FLUID_INTERP_4THORDER as _,
SeventhOrder = ffi::fluid_interp_FLUID_INTERP_7THORDER as _,
}
impl Default for InterpMethod {
fn default() -> Self {
Self::FourthOrder
}
}
impl Synth {
pub fn set_gain(&self, gain: f32) {
unsafe {
ffi::fluid_synth_set_gain(self.handle, gain);
}
}
pub fn get_gain(&self) -> f32 {
unsafe { ffi::fluid_synth_get_gain(self.handle) }
}
pub fn set_polyphony(&self, polyphony: u32) -> Status {
self.zero_ok(unsafe { ffi::fluid_synth_set_polyphony(self.handle, polyphony as _) })
}
pub fn get_polyphony(&self) -> u32 {
unsafe { ffi::fluid_synth_get_polyphony(self.handle) as _ }
}
pub fn get_internal_buffer_size(&self) -> usize {
unsafe { ffi::fluid_synth_get_internal_bufsize(self.handle) as _ }
}
pub fn set_interp_method(&self, chan: Option<u32>, interp_method: InterpMethod) -> Status {
let chan = if let Some(chan) = chan { chan as _ } else { -1 };
self.zero_ok(unsafe {
ffi::fluid_synth_set_interp_method(self.handle, chan, interp_method as _)
})
}
}