WAOfflineContext class

Offline rendering context for non-real-time audio processing. Mirrors Web Audio API OfflineAudioContext.

Useful for testing, offline rendering, and audio export.

final offline = WAOfflineContext(
  numberOfChannels: 2,
  length: 44100,  // 1 second
  sampleRate: 44100,
);

final osc = offline.createOscillator();
osc.frequency.value = 440;
osc.connect(offline.destination);
osc.start();

final renderedBuffer = await offline.startRendering();
Inheritance

Constructors

WAOfflineContext({required int numberOfChannels, required int length, required double sampleRate})
Creates a new OfflineAudioContext.

Properties

audioWorklet WAWorklet
The AudioWorklet interface for registering processors.
no setterinherited
baseLatency double
Base processing latency (seconds) when available.
no setterinherited
contextId int
The context ID (internal).
no setterinherited
currentTime double
Current audio time in seconds.
no setterinherited
destination WADestinationNode
The output destination node.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
length int
Number of sample frames to render.
no setter
listener WAAudioListener
The listener used by spatialized nodes.
no setterinherited
numberOfChannels int
Number of channels in the output.
no setter
offlineSampleRate double
The sample rate specified at construction.
no setter
outputLatency double
Output device latency (seconds) when available.
no setterinherited
renderCapacity WAAudioRenderCapacity
Render-capacity API surface.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sampleRate double
The sample rate of this context.
no setterinherited
sinkId Object
Sink identifier, when available.
no setterinherited
state WAAudioContextState
The current state of the context.
no setterinherited

Methods

close() Future<void>
Close the context and release resources.
inherited
createAnalyser() WAAnalyserNode
Create an AnalyserNode.
inherited
createBiquadFilter() WABiquadFilterNode
Create a BiquadFilterNode.
inherited
createBuffer(int numberOfChannels, int length, double sampleRate) WABuffer
Create an AudioBuffer.
inherited
createBufferSource() WABufferSourceNode
Create an AudioBufferSourceNode.
inherited
createChannelMerger([int numberOfInputs = 6]) WAChannelMergerNode
Create a channel merger node.
inherited
createChannelSplitter([int numberOfOutputs = 6]) WAChannelSplitterNode
Creates a WAChannelSplitterNode.
inherited
createConstantSource() WAConstantSourceNode
Create a ConstantSourceNode.
inherited
createConvolver() WAConvolverNode
Create a ConvolverNode.
inherited
createDelay([double maxDelayTime = 1.0]) WADelayNode
Create a DelayNode with the given maximum delay time.
inherited
createDynamicsCompressor() WADynamicsCompressorNode
Create a DynamicsCompressorNode.
inherited
createGain() WAGainNode
Create a GainNode.
inherited
createIIRFilter(Float64List feedforward, Float64List feedback) WAIIRFilterNode
Create an IIRFilterNode.
inherited
createMachineVoice() List<WANode>
Creates a specialized Machine Voice (Optimized batch creation). Returns nodes in this fixed order: Oscillator, Filter, Gain, Panner, Delay, DelayFb, DelayWet. This is an optimization to avoid main thread blocking during voice creation.
inherited
createMachineVoiceAsync() Future<List<WANode>>
Asynchronously creates a specialized Machine Voice on a worker isolate.
inherited
createMediaElementSource(dynamic mediaElement) WAMediaElementSourceNode
Creates a MediaElementAudioSourceNode from a media element (web).
inherited
createMediaStreamDestination() WAMediaStreamDestNode
Creates a WAMediaStreamDestNode.
inherited
createMediaStreamSource([dynamic stream]) WAMediaStreamSourceNode
Creates a WAMediaStreamSourceNode from the given stream. In this implementation, the stream usually represents the default microphone.
inherited
createMediaStreamTrackSource(dynamic mediaStreamTrack) WAMediaStreamTrackSourceNode
Creates a MediaStreamTrackAudioSourceNode from a media stream track.
inherited
createMicrophoneSource() Future<WAMediaStreamSourceNode>
Creates a microphone source node. On Web, this triggers the permission prompt and gets the stream. On Native, this opens the default input device.
inherited
createNodeId() int
Generates a unique node ID for manual node creation.
inherited
createOscillator() WAOscillatorNode
Create an OscillatorNode.
inherited
createPanner() WAPannerNode
Create a PannerNode (3D spatial panner).
inherited
createPeriodicWave(Float32List real, Float32List imag, {bool disableNormalization = false}) WAPeriodicWave
Creates a WAPeriodicWave instance.
inherited
createScriptProcessor([int bufferSize = 0, int numberOfInputChannels = 2, int numberOfOutputChannels = 2]) WAScriptProcessorNode
Creates a deprecated ScriptProcessorNode shim.
inherited
createStereoPanner() WAStereoPannerNode
Create a StereoPannerNode.
inherited
createWaveShaper() WAWaveShaperNode
Create a WaveShaperNode.
inherited
createWorkletNode(String processorName, {Map<String, double> parameterDefaults = const {}}) WAWorkletNode
Create an AudioWorkletNode.
inherited
decodeAudioData(Uint8List audioData) Future<WABuffer>
Decode audio data from a byte array.
inherited
getOutputTimestamp() WAAudioTimestamp
Output timestamp pair.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resume() Future<void>
Resume audio processing.
inherited
startRendering() Future<WABuffer>
Start rendering and return the resulting AudioBuffer.
suspend() Future<void>
Suspend audio processing.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited