wavecraft_processors/
passthrough.rs1use wavecraft_dsp::{ParamSpec, Processor, ProcessorParams, Transport};
4
5#[derive(Debug, Default, Clone)]
7pub struct PassthroughParams;
8
9impl ProcessorParams for PassthroughParams {
10 fn param_specs() -> &'static [ParamSpec] {
11 &[] }
13}
14
15#[derive(Debug, Default)]
22pub struct PassthroughDsp;
23
24impl Processor for PassthroughDsp {
25 type Params = PassthroughParams;
26
27 fn process(
28 &mut self,
29 _buffer: &mut [&mut [f32]],
30 _transport: &Transport,
31 _params: &Self::Params,
32 ) {
33 }
35
36 fn set_sample_rate(&mut self, _sample_rate: f32) {
37 }
39
40 fn reset(&mut self) {
41 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 fn assert_passthrough_unchanged(mut input: [f32; 4]) {
50 let mut processor = PassthroughDsp;
51 let original = input;
52 let mut buffer = [&mut input[..]];
53
54 let params = PassthroughParams;
55 let transport = Transport::default();
56
57 processor.process(&mut buffer, &transport, ¶ms);
58
59 assert_eq!(input, original);
60 }
61
62 #[test]
63 fn test_passthrough() {
64 assert_passthrough_unchanged([0.5, -0.5, 0.25, -0.25]);
65 }
66
67 #[test]
68 fn test_no_params() {
69 let specs = PassthroughParams::param_specs();
70 assert_eq!(specs.len(), 0);
71 }
72}