wavecraft_dsp/builtins/
passthrough.rs1use crate::traits::{Processor, ProcessorParams, Transport};
4
5#[derive(Debug, Default, Clone)]
7pub struct PassthroughParams;
8
9impl ProcessorParams for PassthroughParams {
10 fn param_specs() -> &'static [crate::traits::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 #[test]
50 fn test_passthrough() {
51 let mut processor = PassthroughDsp;
52 let original = [0.5, -0.5, 0.25, -0.25];
53 let mut data = original;
54 let mut buffer = [&mut data[..]];
55
56 let params = PassthroughParams;
57 let transport = Transport::default();
58
59 processor.process(&mut buffer, &transport, ¶ms);
60
61 for (i, &sample) in data.iter().enumerate() {
63 assert_eq!(sample, original[i]);
64 }
65 }
66
67 #[test]
68 fn test_no_params() {
69 let specs = PassthroughParams::param_specs();
70 assert_eq!(specs.len(), 0);
71 }
72}