pub struct OfflineAudioContext { /* private fields */ }Expand description
The OfflineAudioContext class.
OfflineAudioContext
Implementations§
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn length(&self) -> u32
pub fn length(&self) -> u32
Getter of the length attribute.
OfflineAudioContext.length
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn oncomplete(&self) -> Any
pub fn oncomplete(&self) -> Any
Getter of the oncomplete attribute.
OfflineAudioContext.oncomplete
Sourcepub fn set_oncomplete(&mut self, value: &Any)
pub fn set_oncomplete(&mut self, value: &Any)
Setter of the oncomplete attribute.
OfflineAudioContext.oncomplete
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn new(context_options: &OfflineAudioContextOptions) -> OfflineAudioContext
pub fn new(context_options: &OfflineAudioContextOptions) -> OfflineAudioContext
The new OfflineAudioContext(..) constructor, creating a new OfflineAudioContext instance
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn new_with_number_of_channels_and_length_and_sample_rate(
number_of_channels: u32,
length: u32,
sample_rate: f32,
) -> OfflineAudioContext
pub fn new_with_number_of_channels_and_length_and_sample_rate( number_of_channels: u32, length: u32, sample_rate: f32, ) -> OfflineAudioContext
The new OfflineAudioContext(..) constructor, creating a new OfflineAudioContext instance
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn start_rendering(&self) -> Promise<AudioBuffer>
pub fn start_rendering(&self) -> Promise<AudioBuffer>
The startRendering method.
OfflineAudioContext.startRendering
Source§impl OfflineAudioContext
impl OfflineAudioContext
Sourcepub fn resume(&self) -> Promise<Undefined>
pub fn resume(&self) -> Promise<Undefined>
The resume method.
OfflineAudioContext.resume
Methods from Deref<Target = BaseAudioContext>§
Sourcepub fn destination(&self) -> AudioDestinationNode
pub fn destination(&self) -> AudioDestinationNode
Getter of the destination attribute.
BaseAudioContext.destination
Examples found in repository?
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn sample_rate(&self) -> f32
pub fn sample_rate(&self) -> f32
Getter of the sampleRate attribute.
BaseAudioContext.sampleRate
Sourcepub fn current_time(&self) -> f64
pub fn current_time(&self) -> f64
Getter of the currentTime attribute.
BaseAudioContext.currentTime
Sourcepub fn listener(&self) -> AudioListener
pub fn listener(&self) -> AudioListener
Getter of the listener attribute.
BaseAudioContext.listener
Sourcepub fn state(&self) -> AudioContextState
pub fn state(&self) -> AudioContextState
Getter of the state attribute.
BaseAudioContext.state
Sourcepub fn render_quantum_size(&self) -> u32
pub fn render_quantum_size(&self) -> u32
Getter of the renderQuantumSize attribute.
BaseAudioContext.renderQuantumSize
Sourcepub fn audio_worklet(&self) -> AudioWorklet
pub fn audio_worklet(&self) -> AudioWorklet
Getter of the audioWorklet attribute.
BaseAudioContext.audioWorklet
Sourcepub fn onstatechange(&self) -> Any
pub fn onstatechange(&self) -> Any
Getter of the onstatechange attribute.
BaseAudioContext.onstatechange
Sourcepub fn set_onstatechange(&mut self, value: &Any)
pub fn set_onstatechange(&mut self, value: &Any)
Setter of the onstatechange attribute.
BaseAudioContext.onstatechange
Sourcepub fn create_analyser(&self) -> AnalyserNode
pub fn create_analyser(&self) -> AnalyserNode
The createAnalyser method.
BaseAudioContext.createAnalyser
Sourcepub fn create_biquad_filter(&self) -> BiquadFilterNode
pub fn create_biquad_filter(&self) -> BiquadFilterNode
The createBiquadFilter method.
BaseAudioContext.createBiquadFilter
Sourcepub fn create_buffer(
&self,
number_of_channels: u32,
length: u32,
sample_rate: f32,
) -> AudioBuffer
pub fn create_buffer( &self, number_of_channels: u32, length: u32, sample_rate: f32, ) -> AudioBuffer
The createBuffer method.
BaseAudioContext.createBuffer
Sourcepub fn create_buffer_source(&self) -> AudioBufferSourceNode
pub fn create_buffer_source(&self) -> AudioBufferSourceNode
The createBufferSource method.
BaseAudioContext.createBufferSource
Sourcepub fn create_channel_merger(&self) -> ChannelMergerNode
pub fn create_channel_merger(&self) -> ChannelMergerNode
The createChannelMerger method.
BaseAudioContext.createChannelMerger
Sourcepub fn create_channel_merger_with_number_of_inputs(
&self,
number_of_inputs: u32,
) -> ChannelMergerNode
pub fn create_channel_merger_with_number_of_inputs( &self, number_of_inputs: u32, ) -> ChannelMergerNode
The createChannelMerger method.
BaseAudioContext.createChannelMerger
Sourcepub fn create_channel_splitter(&self) -> ChannelSplitterNode
pub fn create_channel_splitter(&self) -> ChannelSplitterNode
The createChannelSplitter method.
BaseAudioContext.createChannelSplitter
Sourcepub fn create_channel_splitter_with_number_of_outputs(
&self,
number_of_outputs: u32,
) -> ChannelSplitterNode
pub fn create_channel_splitter_with_number_of_outputs( &self, number_of_outputs: u32, ) -> ChannelSplitterNode
The createChannelSplitter method.
BaseAudioContext.createChannelSplitter
Sourcepub fn create_constant_source(&self) -> ConstantSourceNode
pub fn create_constant_source(&self) -> ConstantSourceNode
The createConstantSource method.
BaseAudioContext.createConstantSource
Sourcepub fn create_convolver(&self) -> ConvolverNode
pub fn create_convolver(&self) -> ConvolverNode
The createConvolver method.
BaseAudioContext.createConvolver
Sourcepub fn create_delay(&self) -> DelayNode
pub fn create_delay(&self) -> DelayNode
The createDelay method.
BaseAudioContext.createDelay
Sourcepub fn create_delay_with_max_delay_time(&self, max_delay_time: f64) -> DelayNode
pub fn create_delay_with_max_delay_time(&self, max_delay_time: f64) -> DelayNode
The createDelay method.
BaseAudioContext.createDelay
Sourcepub fn create_dynamics_compressor(&self) -> DynamicsCompressorNode
pub fn create_dynamics_compressor(&self) -> DynamicsCompressorNode
The createDynamicsCompressor method.
BaseAudioContext.createDynamicsCompressor
Sourcepub fn create_gain(&self) -> GainNode
pub fn create_gain(&self) -> GainNode
The createGain method.
BaseAudioContext.createGain
Sourcepub fn create_iir_filter(
&self,
feedforward: TypedArray<f64>,
feedback: TypedArray<f64>,
) -> IIRFilterNode
pub fn create_iir_filter( &self, feedforward: TypedArray<f64>, feedback: TypedArray<f64>, ) -> IIRFilterNode
The createIIRFilter method.
BaseAudioContext.createIIRFilter
Sourcepub fn create_oscillator(&self) -> OscillatorNode
pub fn create_oscillator(&self) -> OscillatorNode
The createOscillator method.
BaseAudioContext.createOscillator
Examples found in repository?
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn create_panner(&self) -> PannerNode
pub fn create_panner(&self) -> PannerNode
The createPanner method.
BaseAudioContext.createPanner
Sourcepub fn create_periodic_wave(
&self,
real: TypedArray<f32>,
imag: TypedArray<f32>,
) -> PeriodicWave
pub fn create_periodic_wave( &self, real: TypedArray<f32>, imag: TypedArray<f32>, ) -> PeriodicWave
The createPeriodicWave method.
BaseAudioContext.createPeriodicWave
Sourcepub fn create_periodic_wave_with_constraints(
&self,
real: TypedArray<f32>,
imag: TypedArray<f32>,
constraints: &PeriodicWaveConstraints,
) -> PeriodicWave
pub fn create_periodic_wave_with_constraints( &self, real: TypedArray<f32>, imag: TypedArray<f32>, constraints: &PeriodicWaveConstraints, ) -> PeriodicWave
The createPeriodicWave method.
BaseAudioContext.createPeriodicWave
Sourcepub fn create_script_processor(&self) -> ScriptProcessorNode
pub fn create_script_processor(&self) -> ScriptProcessorNode
The createScriptProcessor method.
BaseAudioContext.createScriptProcessor
Sourcepub fn create_script_processor_with_buffer_size(
&self,
buffer_size: u32,
) -> ScriptProcessorNode
pub fn create_script_processor_with_buffer_size( &self, buffer_size: u32, ) -> ScriptProcessorNode
The createScriptProcessor method.
BaseAudioContext.createScriptProcessor
Sourcepub fn create_script_processor_with_buffer_size_and_number_of_input_channels(
&self,
buffer_size: u32,
number_of_input_channels: u32,
) -> ScriptProcessorNode
pub fn create_script_processor_with_buffer_size_and_number_of_input_channels( &self, buffer_size: u32, number_of_input_channels: u32, ) -> ScriptProcessorNode
The createScriptProcessor method.
BaseAudioContext.createScriptProcessor
Sourcepub fn create_script_processor_with_buffer_size_and_number_of_input_channels_and_number_of_output_channels(
&self,
buffer_size: u32,
number_of_input_channels: u32,
number_of_output_channels: u32,
) -> ScriptProcessorNode
pub fn create_script_processor_with_buffer_size_and_number_of_input_channels_and_number_of_output_channels( &self, buffer_size: u32, number_of_input_channels: u32, number_of_output_channels: u32, ) -> ScriptProcessorNode
The createScriptProcessor method.
BaseAudioContext.createScriptProcessor
Sourcepub fn create_stereo_panner(&self) -> StereoPannerNode
pub fn create_stereo_panner(&self) -> StereoPannerNode
The createStereoPanner method.
BaseAudioContext.createStereoPanner
Sourcepub fn create_wave_shaper(&self) -> WaveShaperNode
pub fn create_wave_shaper(&self) -> WaveShaperNode
The createWaveShaper method.
BaseAudioContext.createWaveShaper
Sourcepub fn decode_audio_data(
&self,
audio_data: &ArrayBuffer,
) -> Promise<AudioBuffer>
pub fn decode_audio_data( &self, audio_data: &ArrayBuffer, ) -> Promise<AudioBuffer>
The decodeAudioData method.
BaseAudioContext.decodeAudioData
Sourcepub fn decode_audio_data_with_success_callback(
&self,
audio_data: &ArrayBuffer,
success_callback: &Function,
) -> Promise<AudioBuffer>
pub fn decode_audio_data_with_success_callback( &self, audio_data: &ArrayBuffer, success_callback: &Function, ) -> Promise<AudioBuffer>
The decodeAudioData method.
BaseAudioContext.decodeAudioData
Sourcepub fn decode_audio_data_with_success_callback_and_error_callback(
&self,
audio_data: &ArrayBuffer,
success_callback: &Function,
error_callback: &Function,
) -> Promise<AudioBuffer>
pub fn decode_audio_data_with_success_callback_and_error_callback( &self, audio_data: &ArrayBuffer, success_callback: &Function, error_callback: &Function, ) -> Promise<AudioBuffer>
The decodeAudioData method.
BaseAudioContext.decodeAudioData
Methods from Deref<Target = EventTarget>§
Sourcepub fn add_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn add_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Examples found in repository?
4fn main() {
5 let con = Console::get();
6 let document = window().document();
7 let bodies = document.get_elements_by_tag_name(&"body".into());
8 if bodies.length() == 0 {
9 con.log(&["I Ain't got Nobody!".into()]);
10 return;
11 }
12 let body = bodies.item(0);
13 let mut button = document
14 .create_element(&"BUTTON".into())
15 .dyn_into::<HTMLButtonElement>()
16 .unwrap();
17
18 let style = button.style();
19 style.set_property(&"color".into(), &"red".into());
20 style.set_property(&"background-color".into(), &"#aaf".into());
21 style.set_property(&"border".into(), &"solid".into());
22
23 button.set_text_content(&"Click me".into());
24 button.add_event_listener(
25 &"click".into(),
26 &EventListener::from_closure(move |e: Event| {
27 let p = e.dyn_into::<PointerEvent>().unwrap();
28 con.log(&[p.client_x().into()]);
29 Undefined::VALUE
30 }),
31 );
32 body.append_child(button.dyn_ref::<Node>().unwrap());
33}More examples
4fn main() {
5 let context = AudioContext::new();
6 println!("Got an AudioContext");
7
8 // Create oscillator
9 let mut oscillator = context.create_oscillator();
10 println!("Configuring oscillator");
11 oscillator.set_type_(&OscillatorType::TRIANGLE);
12 oscillator.frequency().set_value(261.63); // Middle C
13
14 let document = window().document();
15 let body = document.get_elements_by_tag_name(&"body".into()).item(0);
16 let mut button = document
17 .create_element(&"BUTTON".into())
18 .dyn_into::<HTMLButtonElement>()
19 .unwrap();
20
21 button.set_text_content(&"Click me".into());
22 button.add_event_listener(
23 &JsString::from("click"),
24 &EventListener::from_closure(move |_e: Event| {
25 println!("Playing");
26 oscillator.connect_with_destination_param(
27 context.destination().unchecked_ref::<AudioParam>(),
28 );
29 oscillator.start_with_when(0.0);
30 println!("All done!");
31 Undefined::VALUE
32 }),
33 );
34 body.append_child(button.dyn_ref::<Node>().unwrap());
35}Sourcepub fn add_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn add_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The addEventListener method.
EventTarget.addEventListener
Sourcepub fn remove_event_listener(
&self,
type_: &JsString,
callback: &EventListener,
) -> Undefined
pub fn remove_event_listener( &self, type_: &JsString, callback: &EventListener, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn remove_event_listener_with_options(
&self,
type_: &JsString,
callback: &EventListener,
options: &Any,
) -> Undefined
pub fn remove_event_listener_with_options( &self, type_: &JsString, callback: &EventListener, options: &Any, ) -> Undefined
The removeEventListener method.
EventTarget.removeEventListener
Sourcepub fn dispatch_event(&self, event: &Event) -> bool
pub fn dispatch_event(&self, event: &Event) -> bool
The dispatchEvent method.
EventTarget.dispatchEvent
Sourcepub fn when(&self, type_: &JsString) -> Observable
pub fn when(&self, type_: &JsString) -> Observable
The when method.
EventTarget.when
Sourcepub fn when_with_options(
&self,
type_: &JsString,
options: &ObservableEventListenerOptions,
) -> Observable
pub fn when_with_options( &self, type_: &JsString, options: &ObservableEventListenerOptions, ) -> Observable
The when method.
EventTarget.when
Methods from Deref<Target = Any>§
Sourcepub fn has_own_property(&self, prop: &str) -> bool
pub fn has_own_property(&self, prop: &str) -> bool
Checks whether a non-inherited property prop exists
Sourcepub fn at<T>(&self, idx: T) -> Val
pub fn at<T>(&self, idx: T) -> Val
Gets the element at index idx. Assumes the underlying js type is indexable
Sourcepub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
pub fn to_vec<V>(&self) -> Vec<V>where
V: FromVal,
Converts the underlying js array to a Vec of V
Sourcepub fn call(&self, f: &str, args: &[Val]) -> Val
pub fn call(&self, f: &str, args: &[Val]) -> Val
Calls the method f with args, can return an undefined js value
Sourcepub fn new(&self, args: &[Val]) -> Val
pub fn new(&self, args: &[Val]) -> Val
Calls the object’s constructor with args constructing a new object
Sourcepub fn invoke(&self, args: &[Val]) -> Val
pub fn invoke(&self, args: &[Val]) -> Val
Invokes the function object with args, can return an undefined js value
Sourcepub fn instanceof(&self, v: Val) -> bool
pub fn instanceof(&self, v: Val) -> bool
Checks whether this Val is an instanceof v
pub fn is_number(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_error(&self) -> bool
pub fn is_function(&self) -> bool
pub fn as_<T>(&self) -> Twhere
T: FromVal,
Trait Implementations§
Source§impl AsMut<Val> for OfflineAudioContext
impl AsMut<Val> for OfflineAudioContext
Source§impl AsRef<Val> for OfflineAudioContext
impl AsRef<Val> for OfflineAudioContext
Source§impl Clone for OfflineAudioContext
impl Clone for OfflineAudioContext
Source§fn clone(&self) -> OfflineAudioContext
fn clone(&self) -> OfflineAudioContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OfflineAudioContext
impl Debug for OfflineAudioContext
Source§impl Deref for OfflineAudioContext
impl Deref for OfflineAudioContext
Source§impl DerefMut for OfflineAudioContext
impl DerefMut for OfflineAudioContext
Source§impl DynCast for OfflineAudioContext
impl DynCast for OfflineAudioContext
Source§fn instanceof(val: &Any) -> bool
fn instanceof(val: &Any) -> bool
val instanceof ThisType.Source§fn unchecked_from_val(v: Any) -> Self
fn unchecked_from_val(v: Any) -> Self
Val into Self.Source§fn unchecked_from_val_ref(v: &Any) -> &Self
fn unchecked_from_val_ref(v: &Any) -> &Self
&Val into &Self.Source§fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
fn unchecked_from_val_mut(v: &mut Any) -> &mut Self
&mut Val into &mut Self.fn has_type<T>(&self) -> boolwhere
T: DynCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: DynCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: DynCast,
fn dyn_mut<T>(&mut self) -> Option<&mut T>where
T: DynCast,
fn unchecked_into<T>(self) -> Twhere
T: DynCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: DynCast,
fn unchecked_mut<T>(&mut self) -> &mut Twhere
T: DynCast,
fn is_instance_of<T>(&self) -> boolwhere
T: DynCast,
Source§fn is_type_of(val: &Val) -> bool
fn is_type_of(val: &Val) -> bool
instanceof.