Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class OfflineAudioContext
- Object
- BaseAudioContext
- 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
From BaseAudioContext
getSampleRate, getCurrentTime, getDestination, getListener, createWaveShaper, createAnalyser, createDynamicsCompressor, createConvolver, createPanner, createAudioProcessor, createAudioProcessor, isAudioProcessorSupported, createMicrophoneSource, isMicrophoneSourceSupported, decodeAudioData, isHrtfSupported, createBuffer, createGain, createDelay, createDelay, createBufferSource, createConstantSource, createOscillator, createBiquadFilter, createIIRFilter, createStereoPanner, createChannelSplitter, createChannelSplitter, createChannelMerger, createChannelMerger, createPeriodicWave, createPeriodicWave
Constructor details
OfflineAudioContext
public OfflineAudioContext(int numberOfChannels, int length, float sampleRate)Parameters
numberOfChannelsint- channels of the result, 1 to 32
lengthint- frames to render, at least 1
sampleRatefloat- frames per second, 3000 to 768000
Method details
getLength
public int getLength()startRendering() produces.Returns
getState
public AudioContextState getState()Returns
startRendering
public AudioData startRendering()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 countThrows
IllegalStateException- if rendering was already started