Struct screech::core::Primary[][src]

pub struct Primary<const BUFFER_SIZE: usize> {
    pub sample_rate: usize,
    // some fields omitted
}
Expand description

Main helper struct to render and manage relations between crate::traits::Source types. Also implements crate::traits::Tracker

use screech::traits::{FromPoints, Source};
use screech::core::{Primary, Stream, DynamicTracker};
use screech::basic::{Clip, Track};

const BUFFER_SIZE: usize = 4;
let sample_rate = 48_000;

let mut primary = Primary::<BUFFER_SIZE>::new(sample_rate);

let mut clip_a = Clip::new(&mut primary, Stream::from_points(vec![0.1, 0.2, 0.2, 0.1]));
let mut clip_b = Clip::new(&mut primary, Stream::from_points(vec![0.0, 0.0, 0.1, 0.3]));
let mut track = Track::new(&mut primary);

track.add_input(clip_a.output);
track.add_input(clip_b.output);
primary.add_monitor(track.output);

assert_eq!(
    primary.sample(vec![&mut clip_a, &mut clip_b, &mut track]).unwrap(),
    &[0.1, 0.1, 0.2, 0.2],
);

assert_eq!(
    primary.sample(vec![&mut clip_a, &mut clip_b, &mut track]).unwrap(),
    &[0.3, 0.3, 0.4, 0.4],
);

assert_eq!(
    primary.sample(vec![&mut clip_a, &mut clip_b, &mut track]).unwrap(),
    &[0.0, 0.0, 0.0, 0.0],
);

Fields

sample_rate: usize

sample rate field used for sampling

Implementations

Create new Primary with a default tracker

Create a new Primary with a supplied tracker

use screech::core::{Primary, BasicTracker};

let tracker = BasicTracker::<256, 8>::new();
let primary = Primary::<128>::with_tracker(Box::new(tracker), 48_000);

add source to the final output

remove source from final output

Output a mono signal

Output an interleaved stereo signal

Sample multiple sources based on their dependencies into a single output vec

Trait Implementations

Return a unique ID

clear source id for reuse

get signal for id

set signal for id

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.