[][src]Trait dasp::signal::bus::SignalBus

pub trait SignalBus: Signal {
    fn bus(self) -> Bus<Self> { ... }
}

An extension to the Signal trait that enables multiple signal outputs.

Required Features

  • When using dasp_signal, this item requires the bus feature to be enabled.
  • When using dasp, this item requires the signal-bus feature to be enabled.

Provided methods

fn bus(self) -> Bus<Self>

Moves the Signal into a Bus from which its output may be divided into multiple other Signals in the form of Outputs.

This method allows to create more complex directed acyclic graph structures that incorporate concepts like sends, side-chaining, etc, rather than being restricted to tree structures where signals can only ever be joined but never divided.

Note: When using multiple Outputs in this fashion, you will need to be sure to pull the frames from each Output in sync (whether per frame or per buffer). This is because when output A requests Frames before output B, those frames must remain available for output B and in turn must be stored in an intermediary ring buffer.

Example

use dasp_signal::{self as signal, Signal};
use dasp_signal::bus::SignalBus;

fn main() {
    let frames = [[0.1], [0.2], [0.3], [0.4], [0.5], [0.6]];
    let signal = signal::from_iter(frames.iter().cloned());
    let bus = signal.bus();
    let mut a = bus.send();
    let mut b = bus.send();
    assert_eq!(a.by_ref().take(3).collect::<Vec<_>>(), vec![[0.1], [0.2], [0.3]]);
    assert_eq!(b.by_ref().take(3).collect::<Vec<_>>(), vec![[0.1], [0.2], [0.3]]);

    let c = bus.send();
    assert_eq!(c.take(3).collect::<Vec<_>>(), vec![[0.4], [0.5], [0.6]]);
    assert_eq!(b.take(3).collect::<Vec<_>>(), vec![[0.4], [0.5], [0.6]]);
    assert_eq!(a.take(3).collect::<Vec<_>>(), vec![[0.4], [0.5], [0.6]]);
}

Required Features

  • When using dasp_signal, this item requires the bus feature to be enabled.
  • When using dasp, this item requires the signal-bus feature to be enabled.
Loading content...

Implementors

impl<T> SignalBus for T where
    T: Signal
[src]

Loading content...