pub struct AddConst<T: Sample + Add<Output = T>> { /* private fields */ }Expand description
AddConst adds a constant value to every sample.
Tags are preserved.
use rustradio::graph::{Graph, GraphRunner};
use rustradio::blocks::{ConstantSource, SignalSourceFloat, AddConst, NullSink};
let mut graph = Graph::new();
// Add a constant value. Could just as well use AddConst instead of Add.
let (src, src_out) = SignalSourceFloat::new(44100.0, 1000.0, 1.0);
// Sum up the streams.
let (sum, sum_out) = AddConst::new(src_out, 1.0);
graph.add(Box::new(src));
graph.add(Box::new(sum));
// Set up dummy sink.
let sink = NullSink::new(sum_out);
graph.run()?;Implementations§
Source§impl<T: Sample + Add<Output = T>> AddConst<T>
impl<T: Sample + Add<Output = T>> AddConst<T>
pub fn new( src: ReadStream<T>, val: T, ) -> (Self, <WriteStream<T> as StreamReadSide>::ReadSide)
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for AddConst<T>where
T: Freeze,
impl<T> RefUnwindSafe for AddConst<T>where
T: RefUnwindSafe,
impl<T> Send for AddConst<T>
impl<T> Sync for AddConst<T>
impl<T> Unpin for AddConst<T>where
T: Unpin,
impl<T> UnwindSafe for AddConst<T>where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more