audioIsRunning() → booleanengineAudio.js:58Check if the audio context is running and available for playback
- Returns
- True if the audio context is running, false when there is none
LittleJS Audio System
audioIsRunning() → booleanengineAudio.js:58Check if the audio context is running and available for playback
createAudioBuffer(sampleChannels, sampleRate) → AudioBufferengineAudio.js:845Copy arrays of samples into a new audio buffer
sampleChannels ArrayArray of arrays of samples (for stereo playback)
sampleRate number optional, default audioDefaultSampleRateSample rate for the sound
getNoteFrequency(semitoneOffset, rootFrequency) → numberengineAudio.js:798Get frequency of a note on a musical scale
semitoneOffset numberHow many semitones away from the root note
rootFrequency number optional, default 220Frequency at semitone offset 0
playAudioBuffer(buffer, volume, rate, pan, loop, gainNode, offset, onended, output, pannerNode) → AudioBufferSourceNode|undefinedengineAudio.js:868Play an audio buffer with given settings The buffer can be shared by any number of sounds playing at once
buffer AudioBufferThe audio buffer to play
volume number optional, default 1How much to scale volume by
rate number optional, default 1The playback rate to use
pan number optional, default 0How much to apply stereo panning
loop boolean optional, default falseTrue if the sound should loop when it reaches the end
gainNode GainNode optionalOptional gain node for volume control while playing (disconnected when the sound ends)
offset number optional, default 0Where to start in the sound, in its own seconds whatever the rate
onended AudioEndedCallback optionalCallback for when the sound ends
output AudioNode|AudioEffectNodes optionalNode or effect to connect the gain to instead of the master gain
pannerNode StereoPannerNode optionalOptional stereo panner for panning while playing, its pan already set (disconnected when the sound ends)
playSamples(sampleChannels, volume, rate, pan, loop, sampleRate, gainNode, offset, onended, output, pannerNode) → AudioBufferSourceNode|undefinedengineAudio.js:823Play cached audio samples with given settings
sampleChannels ArrayArray of arrays of samples to play (for stereo playback)
volume number optional, default 1How much to scale volume by
rate number optional, default 1The playback rate to use
pan number optional, default 0How much to apply stereo panning
loop boolean optional, default falseTrue if the sound should loop when it reaches the end
sampleRate number optional, default audioDefaultSampleRateSample rate for the sound
gainNode GainNode optionalOptional gain node for volume control while playing (disconnected when the sound ends)
offset number optional, default 0Where to start in the sound, in its own seconds whatever the rate
onended AudioEndedCallback optionalCallback for when the sound ends
output AudioNode|AudioEffectNodes optionalNode or effect to connect the gain to instead of the master gain
pannerNode StereoPannerNode optionalOptional stereo panner for panning while playing, its pan already set (disconnected when the sound ends)
setAudioMasterEffect(input, output)engineAudio.js:133Route all sound through an effect between the master gain and the speakers
input AudioNode|AudioEffectNodes optionalNode or effect the master gain connects to
output AudioNode|AudioEffectNodes optionalNode or effect that connects to the audio destination, defaults to the input's output
speak(text, volume, rate, pitch, language) → SpeechSynthesisUtterance|undefinedengineAudio.js:765Speak text with passed in settings
text stringThe text to speak
volume number optional, default 1How much to scale volume by
rate number optional, default 1How quickly to speak
pitch number optional, default 1How much to change the pitch by
language string optionalThe language/accent to use (examples: en, it, ru, ja, zh)
speakStop()engineAudio.js:787Stop all queued speech
zzfx(…zzfxSound) → AudioBufferSourceNode|undefinedengineAudio.js:927Generate and play a ZzFX sound
…zzfxSound ArrayArray of ZzFX parameters, ex. [.5,.5]
zzfxG(volume, randomness, frequency, attack, sustain, release, shape, shapeCurve, slide, deltaSlide, pitchJump, pitchJumpTime, repeatTime, noise, modulation, bitCrush, delay, sustainVolume, decay, tremolo, filter) → Float32ArrayengineAudio.js:954Generate samples for a ZzFX sound
volume number optional, default 1Volume scale (percent)
randomness number optional, default 0.05How much to randomize frequency (percent Hz)
frequency number optional, default 220Frequency of sound (Hz)
attack number optional, default 0Attack time, how fast sound starts (seconds)
sustain number optional, default 0Sustain time, how long sound holds (seconds)
release number optional, default 0.1Release time, how fast sound fades out (seconds)
shape number optional, default 0Shape of the sound wave
shapeCurve number optional, default 1Squareness of wave (0=square, 1=normal, 2=pointy)
slide number optional, default 0How much to slide frequency, 1 is about 500 Hz a second, as ZzFX has it
deltaSlide number optional, default 0How much to change slide each second, in the units of slide
pitchJump number optional, default 0Frequency of pitch jump (Hz)
pitchJumpTime number optional, default 0Time of pitch jump (seconds)
repeatTime number optional, default 0Resets some parameters periodically (seconds)
noise number optional, default 0How much random noise to add (percent)
modulation number optional, default 0Frequency of modulation wave, negative flips phase (Hz)
bitCrush number optional, default 0Resamples at a lower frequency in (samples*100)
delay number optional, default 0Overlap sound with itself for reverb and flanger effects (seconds)
sustainVolume number optional, default 1Volume level for sustain (percent)
decay number optional, default 0Decay time, how long to reach sustain after attack (seconds)
tremolo number optional, default 0Trembling effect, rate controlled by repeat time (percent)
filter number optional, default 0Filter cutoff, positive for HPF, negative for LPF; the cutoff is about twice this in Hz, as ZzFX has it, and its resonance can take the samples past 1
audioContext : AudioContextengineAudio.js:21Audio context used by the engine, undefined outside a browser, where the engine runs headless
audioMasterGain : GainNodeengineAudio.js:29Master gain node for all audio to pass through, made at load so effects can connect to it any time
audioDefaultSampleRate default 44100engineAudio.js:53Default sample rate used for sounds
AudioEffectNodes : ObjectengineAudio.js:120Anything with input and output audio nodes, like an effect from the audio effects plugin
AudioEndedCallback(source)engineAudio.js:803source AudioBufferSourceNodeSoundLoadCallback(sound)engineAudio.js:208sound Sound