Crate web_audio_api
source ·Expand description
A high-level API for processing and synthesizing audio.
Example
use std::fs::File;
use web_audio_api::context::{BaseAudioContext, AudioContext};
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
// set up AudioContext with optimized settings for your hardware
let context = AudioContext::default();
// create an audio buffer from a given file
let file = File::open("samples/sample.wav").unwrap();
let buffer = context.decode_audio_data_sync(file).unwrap();
// play the buffer at given volume
let volume = context.create_gain();
volume.connect(&context.destination());
volume.gain().set_value(0.5);
let mut buffer_source = context.create_buffer_source();
buffer_source.connect(&volume);
buffer_source.set_buffer(buffer);
// create oscillator branch
let mut osc = context.create_oscillator();
osc.connect(&context.destination());
// start the sources
buffer_source.start();
osc.start();
// enjoy listening
std::thread::sleep(std::time::Duration::from_secs(4));
Modules
- The
BaseAudioContext
interface and theAudioContext
andOfflineAudioContext
types - Primitives of the MediaDevices API
- Primitives of the Media Recorder API
- Primitives of the Media Capture and Streams API
- The AudioNode interface and concrete types
- Primitives related to audio graph rendering
- User-defined audio nodes and processors
Structs
- Memory-resident audio asset, basically a matrix of channels * samples
- Options for constructing an
AudioBuffer
- Represents the position and orientation of the person listening to the audio scene
- AudioParam controls an individual aspect of an AudioNode’s functionality, such as volume.
- Options for constructing an
AudioParam
- Provider for rendering performance metrics
- Performance metrics of the rendering thread
- Options for constructing an
AudioRenderCapacity
- The Error Event interface
- The Event interface
- Shim of the
<audio>
element which allows you to efficiently play and seek audio from disk PeriodicWave
represents an arbitrary periodic waveform to be used with anOscillatorNode
.- Options for constructing a
PeriodicWave
Enums
- Precision of AudioParam value calculation per render quantum
Constants
- Maximum number of channels for audio processing