Skip to main content

SoundDataSourceNode

Struct SoundDataSourceNode 

Source
pub struct SoundDataSourceNode { /* private fields */ }

Implementations§

Source§

impl SoundDataSourceNode

Source

pub fn ended(&self) -> bool

Source

pub fn try_start(&self, time: f64) -> Result<(), GraphError>

Examples found in repository?
examples/sound_data_bridge.rs (line 95)
91fn build_bridge(context: &mut AudioContext) -> Result<AnalyserNode, Box<dyn Error>> {
92    let source = context.create_sound_data_source(ProceduralPhrase {
93        notes: vec![(261.63, 0.35), (329.63, 0.35), (392.0, 0.5), (523.25, 0.7)],
94    });
95    source.try_start(0.0)?;
96    source.try_stop(2.2)?;
97
98    let filter = context.create_biquad_filter();
99    filter.set_type(BiquadFilterType::Lowpass);
100    filter.frequency().set_value_at_time(700.0, 0.0)?;
101    filter
102        .frequency()
103        .linear_ramp_to_value_at_time(2_200.0, 1.6)?;
104    let pan = context.try_create_stereo_panner_with_options(StereoPannerOptions { pan: -0.3 })?;
105    pan.pan().linear_ramp_to_value_at_time(0.3, 2.0)?;
106    let analyser = context.create_analyser();
107    let output = context.create_gain();
108    output.gain().set_value(0.65)?;
109
110    context.connect(&source, &filter)?;
111    context.connect(&filter, &pan)?;
112    context.connect(&pan, &output)?;
113    context.connect(&output, &analyser)?;
114    context.connect(&analyser, context.destination())?;
115    Ok(analyser)
116}
Source

pub fn try_stop(&self, time: f64) -> Result<(), GraphError>

Examples found in repository?
examples/sound_data_bridge.rs (line 96)
91fn build_bridge(context: &mut AudioContext) -> Result<AnalyserNode, Box<dyn Error>> {
92    let source = context.create_sound_data_source(ProceduralPhrase {
93        notes: vec![(261.63, 0.35), (329.63, 0.35), (392.0, 0.5), (523.25, 0.7)],
94    });
95    source.try_start(0.0)?;
96    source.try_stop(2.2)?;
97
98    let filter = context.create_biquad_filter();
99    filter.set_type(BiquadFilterType::Lowpass);
100    filter.frequency().set_value_at_time(700.0, 0.0)?;
101    filter
102        .frequency()
103        .linear_ramp_to_value_at_time(2_200.0, 1.6)?;
104    let pan = context.try_create_stereo_panner_with_options(StereoPannerOptions { pan: -0.3 })?;
105    pan.pan().linear_ramp_to_value_at_time(0.3, 2.0)?;
106    let analyser = context.create_analyser();
107    let output = context.create_gain();
108    output.gain().set_value(0.65)?;
109
110    context.connect(&source, &filter)?;
111    context.connect(&filter, &pan)?;
112    context.connect(&pan, &output)?;
113    context.connect(&output, &analyser)?;
114    context.connect(&analyser, context.destination())?;
115    Ok(analyser)
116}

Trait Implementations§

Source§

impl Clone for SoundDataSourceNode

Source§

fn clone(&self) -> SoundDataSourceNode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SoundDataSourceNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AudioNodeHandle for T
where T: AudioNodeHandlePrivate + ?Sized,

Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.