Package com.codename1.media.audio


package com.codename1.media.audio

A real-time and offline audio graph modelled on the W3C Web Audio API.

Sources (AudioBufferSourceNode, OscillatorNode, ConstantSourceNode) feed processing nodes (GainNode, DelayNode, BiquadFilterNode, IIRFilterNode, StereoPannerNode, ChannelSplitterNode, ChannelMergerNode) that end at the context's destination. Node parameters are AudioParams with sample-accurate automation and can be modulated by other nodes.

ConvolverNode (reverb), DynamicsCompressorNode, WaveShaperNode (distortion) and AnalyserNode (spectrum and waveform for visualisers) complete the processing set.

PannerNode places a source in 3D around the context's AudioListener, with the specification's distance models and sound cones. Its PanningModel.HRTF mode renders binaurally for headphones from a structural head model (interaural delay, head shadow and pinna echoes), so it is the same portable code, with the same result, on every platform.

OfflineAudioContext renders to memory on every platform. AudioContext plays to the speaker where the platform has a real-time output; call AudioContext.isSupported() first. Names and behaviour follow the specification, so Web Audio material applies with Java naming: gain.gain.value = 0.5 becomes gain.getGain().setValue(0.5f).

The graph is rendered by portable code, so a graph sounds the same on every platform it runs on.