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
ix!();
use crate::*;
#[enum_dispatch]
pub trait GetRingout {
fn get_ringout(&self) -> Ringout;
fn get_ringout_counter(&self) -> NumberOfBlocks;
}
#[enum_dispatch]
pub trait SetRingout {
fn ringout_counter_incr(&mut self);
fn ringout_counter_reset(&mut self);
}
#[enum_dispatch]
pub trait ProcessRingout :
Process
+ ProcessOnlyControl
+ GetRingout
+ SetRingout
{
unsafe fn process_ringout<const N: usize>(&mut self,
data_l: *mut f32,
data_r: *mut f32,
indata_present: bool) -> OutputDataPresent
{
let data_l: &mut [f32; N] = std::slice::from_raw_parts_mut(data_l, N).try_into().unwrap();
let data_r: &mut [f32; N] = std::slice::from_raw_parts_mut(data_r, N).try_into().unwrap();
let mut do_process = false;
let mut decay_max = 0;
match self.get_ringout() {
Ringout::On {counter: _, decay } => {
match indata_present {
true => {
self.ringout_counter_reset();
do_process = true;
decay_max = decay;
},
false => {
self.ringout_counter_incr();
},
}
},
Ringout::Off => {
do_process = true;
},
}
if (self.get_ringout_counter() < decay_max) || do_process {
self.process::<N>(data_l,data_r);
true
} else {
self.process_only_control::<N>();
false
}
}
}