[][src]Struct sonant::Synth

pub struct Synth<'a> { /* fields omitted */ }

The main struct for audio synthesis.

Synth implements Iterator, so calling the next method on it will generate the next sample.

Currently only generates 2-channel f32 samples at the given sample_rate.


impl<'a> Synth<'a>[src]

#[must_use] pub fn new(song: &'a Song, seed: (u64, u64), sample_rate: f32) -> Self[src]

Create a Synth that will play the provided Song. The optional seed will be used for the noise generator. Synth implements Iterator and generates two stereo samples at a time.

use byteorder::{ByteOrder, NativeEndian};
use getrandom::getrandom;
use sonant::{Song, Synth};

let song = Song::from_slice(include_bytes!("../examples/poseidon.snt"))?;

// Create a seed for the PRNG
let mut seed = [0_u8; 16];
getrandom(&mut seed).expect("failed to getrandom");
let seed = (

let synth = Synth::new(&song, seed, 44100.0);
for [sample_l, sample_r] in synth {
    // Do something with the samples

Trait Implementations

impl<'a> Iterator for Synth<'a>[src]

type Item = [f32; 2]

The type of the elements being iterated over.

impl<'a> Debug for Synth<'a>[src]

Auto Trait Implementations

impl<'a> Send for Synth<'a>

impl<'a> Sync for Synth<'a>

impl<'a> Unpin for Synth<'a>

impl<'a> UnwindSafe for Synth<'a>

impl<'a> RefUnwindSafe for Synth<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized