pub struct PeriodicWave { /* private fields */ }
Expand description
PeriodicWave
represents an arbitrary periodic waveform to be used with an OscillatorNode
.
- MDN documentation: https://developer.mozilla.org/en-US/docs/Web/API/PeriodicWave
- specification: https://webaudio.github.io/web-audio-api/#PeriodicWave
- see also:
BaseAudioContext::create_periodic_wave
- see also:
OscillatorNode
§Usage
use web_audio_api::context::{BaseAudioContext, AudioContext};
use web_audio_api::{PeriodicWave, PeriodicWaveOptions};
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
let context = AudioContext::default();
// generate a simple waveform with 2 harmonics
let options = PeriodicWaveOptions {
real: Some(vec![0., 0., 0.]),
imag: Some(vec![0., 0.5, 0.5]),
disable_normalization: false,
};
let periodic_wave = PeriodicWave::new(&context, options);
let mut osc = context.create_oscillator();
osc.set_periodic_wave(periodic_wave);
osc.connect(&context.destination());
osc.start();
§Examples
cargo run --release --example oscillators
Implementations§
Source§impl PeriodicWave
impl PeriodicWave
Sourcepub fn new<C: BaseAudioContext>(
_context: &C,
options: PeriodicWaveOptions,
) -> Self
pub fn new<C: BaseAudioContext>( _context: &C, options: PeriodicWaveOptions, ) -> Self
Returns a PeriodicWave
§Arguments
real
- The real parameter represents an array of cosine terms of Fourier series.imag
- The imag parameter represents an array of sine terms of Fourier series.constraints
- The constraints parameter specifies the normalization mode of thePeriodicWave
§Panics
Will panic if:
real
is defined and its length is less than 2imag
is defined and its length is less than 2real
andimag
are defined and theirs lengths are not equalPeriodicWave
is more than 8192 components
Trait Implementations§
Source§impl Clone for PeriodicWave
impl Clone for PeriodicWave
Source§fn clone(&self) -> PeriodicWave
fn clone(&self) -> PeriodicWave
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PeriodicWave
impl Debug for PeriodicWave
Source§impl Default for PeriodicWave
impl Default for PeriodicWave
Source§fn default() -> PeriodicWave
fn default() -> PeriodicWave
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PeriodicWave
impl RefUnwindSafe for PeriodicWave
impl Send for PeriodicWave
impl Sync for PeriodicWave
impl Unpin for PeriodicWave
impl UnwindSafe for PeriodicWave
Blanket Implementations§
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