pub struct PeriodicWave { /* private fields */ }
Expand description

PeriodicWave represents an arbitrary periodic waveform to be used with an 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 osc = context.create_oscillator();
osc.set_periodic_wave(periodic_wave);
osc.connect(&context.destination());
osc.start();

Examples

  • cargo run --release --example oscillators

Implementations

Returns a PeriodicWave

Arguments
  • real - The real parameter represents an array of cosine terms of Fourrier series.
  • imag - The imag parameter represents an array of sine terms of Fourrier series.
  • constraints - The constraints parameter specifies the normalization mode of the PeriodicWave
Panics

Will panic if:

  • real is defined and its length is less than 2
  • imag is defined and its length is less than 2
  • real and imag are defined and theirs lengths are not equal
  • PeriodicWave is more than 8192 components

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.