pub struct AudioWorkletNode { /* private fields */ }Implementations§
Source§impl AudioWorkletNode
impl AudioWorkletNode
pub fn parameter(&self, name: &str) -> Option<AudioParamHandle>
Sourcepub fn param(&self, name: &str) -> Option<AudioParamHandle>
pub fn param(&self, name: &str) -> Option<AudioParamHandle>
Examples found in repository?
examples/worklet_instrument.rs (line 136)
90fn build_worklet_patch(
91 context: &mut AudioContext,
92 stop_time: f64,
93) -> Result<AudioWorkletNode, Box<dyn Error>> {
94 let osc = context.create_oscillator();
95 osc.set_type(Waveform::Sawtooth);
96 osc.frequency().set_value(165.0)?;
97 osc.frequency()
98 .linear_ramp_to_value_at_time(220.0, stop_time)?;
99 osc.try_start(0.0)?;
100 osc.try_stop(stop_time)?;
101
102 let mut parameter_data = HashMap::new();
103 parameter_data.insert("depth".to_owned(), 0.65);
104 parameter_data.insert("mix".to_owned(), 0.55);
105 let mut processor_options = HashMap::new();
106 processor_options.insert("rate_hz".to_owned(), "5.5".to_owned());
107 processor_options.insert("drive".to_owned(), "1.35".to_owned());
108 processor_options.insert("stop_after".to_owned(), stop_time.to_string());
109 let worklet = context.try_create_audio_worklet_node(
110 FoldbackTremolo { phase: 0.0 },
111 AudioWorkletNodeOptions {
112 number_of_inputs: 1,
113 number_of_outputs: 1,
114 output_channel_count: Some(vec![2]),
115 parameter_descriptors: vec![
116 AudioWorkletParameterDescriptor {
117 name: "depth".to_owned(),
118 default_value: 0.5,
119 min_value: 0.0,
120 max_value: 1.0,
121 automation_rate: AutomationRate::ARate,
122 },
123 AudioWorkletParameterDescriptor {
124 name: "mix".to_owned(),
125 default_value: 0.6,
126 min_value: 0.0,
127 max_value: 1.0,
128 automation_rate: AutomationRate::KRate,
129 },
130 ],
131 parameter_data,
132 processor_options,
133 },
134 )?;
135 worklet
136 .param("depth")
137 .expect("depth parameter")
138 .linear_ramp_to_value_at_time(0.15, stop_time)?;
139 worklet
140 .param("mix")
141 .expect("mix parameter")
142 .set_target_at_time(0.85, 1.25, 0.5)?;
143 let output = context.create_gain();
144 output.gain().set_value(0.18)?;
145 context.connect(osc, &worklet)?;
146 context.connect(&worklet, &output)?;
147 context.connect(&output, context.destination())?;
148 Ok(worklet)
149}Source§impl AudioWorkletNode
impl AudioWorkletNode
pub fn channel_count(&self) -> usize
pub fn channel_count_mode(&self) -> ChannelCountMode
pub fn channel_interpretation(&self) -> ChannelInterpretation
pub fn try_set_channel_config( &self, channel_count: usize, channel_count_mode: ChannelCountMode, channel_interpretation: ChannelInterpretation, ) -> Result<(), GraphError>
Trait Implementations§
Source§impl Clone for AudioWorkletNode
impl Clone for AudioWorkletNode
Source§fn clone(&self) -> AudioWorkletNode
fn clone(&self) -> AudioWorkletNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AudioWorkletNode
impl RefUnwindSafe for AudioWorkletNode
impl Send for AudioWorkletNode
impl Sync for AudioWorkletNode
impl Unpin for AudioWorkletNode
impl UnsafeUnpin for AudioWorkletNode
impl UnwindSafe for AudioWorkletNode
Blanket Implementations§
impl<T> AudioNodeHandle for Twhere
T: AudioNodeHandlePrivate + ?Sized,
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