Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class OfflineAudioContext

  1. Object
  2. BaseAudioContext
  3. OfflineAudioContext

Renders an audio graph to memory as fast as the device can, the Web Audio OfflineAudioContext. It needs no audio hardware, so it works on every platform: use it to bounce a mix, pre-render effects, or test a graph.

OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
OscillatorNode osc = audio.createOscillator();
osc.connect(audio.getDestination());
osc.start();
AudioData oneSecond = audio.startRendering();

Constructors

public OfflineAudioContext(int numberOfChannels, int length, float sampleRate)Creates an offline context.

Methods

public int getLength()The number of frames startRendering() produces.
public AudioContextState getState()The life cycle state.
public AudioData startRendering()Renders the whole graph on the calling thread and returns the result.

Inherited methods

Constructor details

OfflineAudioContext

public OfflineAudioContext(int numberOfChannels, int length, float sampleRate)
Creates an offline context.

Parameters

numberOfChannels int
channels of the result, 1 to 32
length int
frames to render, at least 1
sampleRate float
frames per second, 3000 to 768000

Method details

getLength

public int getLength()
The number of frames startRendering() produces.

Returns

frames

getState

public AudioContextState getState()
The life cycle state.

Returns

the state

startRendering

public AudioData startRendering()
Renders the whole graph on the calling thread and returns the result. onended callbacks run on this thread between render quanta. Do not call it on the EDT for long renders.

Returns

getLength() frames with the destination’s channel count

Throws

IllegalStateException
if rendering was already started