Skip to main content

rustradio/
xor.rs

1//! Xor two streams.
2use crate::Sample;
3use crate::stream::{ReadStream, WriteStream};
4
5/// Xors a constant value to every sample.
6#[derive(rustradio_macros::Block)]
7#[rustradio(crate, new, sync)]
8pub struct Xor<T>
9where
10    T: Sample + std::ops::BitXor<Output = T>,
11{
12    #[rustradio(in)]
13    a: ReadStream<T>,
14    #[rustradio(in)]
15    b: ReadStream<T>,
16    #[rustradio(out)]
17    dst: WriteStream<T>,
18}
19
20impl<T> Xor<T>
21where
22    T: Sample + std::ops::BitXor<Output = T>,
23{
24    fn process_sync(&self, a: T, b: T) -> T {
25        a ^ b
26    }
27}