Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public abstract class BaseAudioContext
- Object
- BaseAudioContext
Known subtypesAudioContext, OfflineAudioContext
What AudioContext (real time, to the speaker) and OfflineAudioContext
(as fast as possible, to memory) share: the clock, the destination and the
factory methods for every node, the Web Audio BaseAudioContext.
The graph is rendered in quanta of 128 frames. Building and changing it is allowed from any thread; every change is queued and applied by the renderer at the start of its next quantum, so the renderer never waits on a lock.
Methods
Inherited methods
Method details
getSampleRate
public float getSampleRate()Returns
getCurrentTime
public double getCurrentTime()Returns
getDestination
public AudioDestinationNode getDestination()Returns
getListener
public AudioListener getListener()PannerNode of this context is heard from.Returns
createWaveShaper
public WaveShaperNode createWaveShaper()Returns
createAnalyser
public AnalyserNode createAnalyser()Returns
createDynamicsCompressor
public DynamicsCompressorNode createDynamicsCompressor()Returns
createConvolver
public ConvolverNode createConvolver()Returns
createPanner
public PannerNode createPanner()Returns
createAudioProcessor
public AudioProcessorNode createAudioProcessor(AudioProcessor processor, int numberOfInputs, int numberOfOutputs, int[] outputChannelCount, AudioParamDescriptor[] parameters)new AudioWorkletNode(...). There is no module to load: the processor
is an ordinary object, called on the render thread.Parameters
processorAudioProcessor- the DSP
numberOfInputsint- inputs the node has
numberOfOutputsint- outputs the node has
outputChannelCountint[]- channels of each output; null gives every output one
parametersAudioParamDescriptor[]- the parameters to create, or null for none
Returns
createAudioProcessor
public AudioProcessorNode createAudioProcessor(AudioProcessor processor, int outputChannels)Parameters
processorAudioProcessor- the DSP
outputChannelsint- the output’s channel count
Returns
isAudioProcessorSupported
public boolean isAudioProcessorSupported()createAudioProcessor runs custom DSP here. It is always
true, since the whole graph is rendered by portable code; the method
exists so code written for the Web Audio worklet’s spotty support can ask.Returns
createMicrophoneSource
public MicrophoneSourceNode createMicrophoneSource(AudioBuffer capture)createMediaStreamSource for a microphone. Record with
MediaRecorderBuilder.redirectToAudioBuffer(true) and pass the buffer
from MediaManager.getAudioBuffer(path, true, size).Parameters
captureAudioBuffer- the buffer the recorder fills
Returns
isMicrophoneSourceSupported
public boolean isMicrophoneSourceSupported()AudioBuffer, which
createMicrophoneSource plays. Recording still needs the user’s
permission, which the recorder asks for.Returns
decodeAudioData
public AudioData decodeAudioData(byte[] encoded)Decodes an encoded audio file into an AudioData for an
AudioBufferSourceNode, the counterpart of decodeAudioData.
The decoder is portable code and reads RIFF WAVE (integer PCM of 8 to 32 bits, float of 32 or 64 bits). It answers null for anything else; convert compressed audio to WAVE ahead of time. The result keeps the file’s sample rate, and a buffer source resamples it as it plays.
Parameters
encodedbyte[]- the file’s bytes
Returns
isHrtfSupported
public boolean isHrtfSupported()PanningModel.HRTF renders binaurally on this platform. It is
always true: the head model is portable code. The method exists so code
written for platforms where HRTF might fall back to equal-power can ask.Returns
getState
public abstract AudioContextState getState()Returns
createBuffer
public AudioData createBuffer(int numberOfChannels, int length, float sampleRate)AudioData to fill in and play.Parameters
numberOfChannelsint- 1 to 32
lengthint- frames
sampleRatefloat- frames per second; need not match the context
Returns
createGain
public GainNode createGain()Returns
createDelay
public DelayNode createDelay()Returns
createDelay
public DelayNode createDelay(double maxDelayTime)Parameters
maxDelayTimedouble- the longest delay in seconds, more than 0 and less than 180
Returns
createBufferSource
public AudioBufferSourceNode createBufferSource()AudioData.Returns
createConstantSource
public ConstantSourceNode createConstantSource()Returns
createOscillator
public OscillatorNode createOscillator()Returns
createBiquadFilter
public BiquadFilterNode createBiquadFilter()Returns
createIIRFilter
public IIRFilterNode createIIRFilter(double[] feedforward, double[] feedback)Parameters
feedforwarddouble[]- the numerator coefficients, 1 to 20 of them, not all 0
feedbackdouble[]- the denominator coefficients, 1 to 20 of them, the first not 0
Returns
createStereoPanner
public StereoPannerNode createStereoPanner()Returns
createChannelSplitter
public ChannelSplitterNode createChannelSplitter()Returns
createChannelSplitter
public ChannelSplitterNode createChannelSplitter(int numberOfOutputs)Parameters
numberOfOutputsint- 1 to 32
Returns
createChannelMerger
public ChannelMergerNode createChannelMerger()Returns
createChannelMerger
public ChannelMergerNode createChannelMerger(int numberOfInputs)Parameters
numberOfInputsint- 1 to 32
Returns
createPeriodicWave
public PeriodicWave createPeriodicWave(float[] real, float[] imag)OscillatorNode.Parameters
realfloat[]- cosine coefficients; index 0, the DC term, is ignored
imagfloat[]- sine coefficients, the same length as
real
Returns
createPeriodicWave
public PeriodicWave createPeriodicWave(float[] real, float[] imag, boolean disableNormalization)OscillatorNode.Parameters
realfloat[]- cosine coefficients; index 0, the DC term, is ignored
imagfloat[]- sine coefficients, the same length as
real disableNormalizationboolean- true to keep the coefficients’ own amplitude rather than scaling the peak to 1