rustradio/multiply_const.rs
1//! Multiply stream by a constant value.
2use crate::Sample;
3use crate::stream::{ReadStream, WriteStream};
4
5/// Multiply stream by a constant value.
6#[derive(rustradio_macros::Block)]
7#[rustradio(crate, new, sync, bound = "T: Sample + std::ops::Mul<Output=T>")]
8pub struct MultiplyConst<T> {
9 val: T,
10 #[rustradio(in)]
11 src: ReadStream<T>,
12 #[rustradio(out)]
13 dst: WriteStream<T>,
14}
15
16impl<T> MultiplyConst<T>
17where
18 T: Sample + std::ops::Mul<Output = T>,
19{
20 fn process_sync(&self, x: T) -> T {
21 x * self.val
22 }
23}