WebAudio
clay.base.BaseAudio → clay.web.WebAudio (Class)
Static Members
MAX_WORKLET_PARAMS: Int
Instance Members
context: js.html.audio.AudioContext
active: Bool
init(): Void
Name | Type |
---|---|
delta |
Float |
shutdown(): Void
Name | Type | Default |
---|---|---|
index |
Int | |
name |
String | "" |
volume |
Float | 1.0 |
Name | Type |
---|---|
index |
Int |
Name | Type |
---|---|
busIndex |
Int |
volume |
Float |
Name | Type |
---|---|
busIndex |
Int |
Returns |
---|
Float |
Name | Type |
---|---|
busIndex |
Int |
active |
Bool |
Name | Type | Default |
---|---|---|
name |
String | |
url |
String | |
callback |
Function | (optional) |
Name | Type | Default |
---|---|---|
busIndex |
Int | |
workletName |
String | |
options |
Dynamic | (optional) |
onReady |
Function | (optional) |
Returns |
---|
Bool |
Name | Type |
---|---|
busIndex |
Int |
Name | Type |
---|---|
busIndex |
Int |
message |
Dynamic |
Name | Type |
---|---|
busIndex |
Int |
ready |
Function |
Name | Type |
---|---|
busIndex |
Int |
paramName |
String |
value |
Float |
Name | Type |
---|---|
busIndex |
Int |
paramName |
String |
value |
Float |
Name | Type |
---|---|
busIndex |
Int |
paramIndex |
Int |
value |
Float |
Name | Type |
---|---|
busIndex |
Int |
paramIndex |
Int |
value |
Float |
Name | Type |
---|---|
busIndex |
Int |
paramIndex |
Int |
Returns |
---|
Float |
play(source: clay.audio.AudioSource, volume: Float, paused: Bool, ?busIndex: Int = DEFAULT_BUS): clay.audio.AudioHandle
Name | Type | Default |
---|---|---|
source |
clay.audio.AudioSource | |
volume |
Float | |
paused |
Bool | |
busIndex |
Int | DEFAULT_BUS |
Returns |
---|
clay.audio.AudioHandle |
loop(source: clay.audio.AudioSource, volume: Float, paused: Bool, ?busIndex: Int = DEFAULT_BUS): clay.audio.AudioHandle
Name | Type | Default |
---|---|---|
source |
clay.audio.AudioSource | |
volume |
Float | |
paused |
Bool | |
busIndex |
Int | DEFAULT_BUS |
Returns |
---|
clay.audio.AudioHandle |
pause(handle: clay.audio.AudioHandle): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
unPause(handle: clay.audio.AudioHandle): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
stop(handle: clay.audio.AudioHandle): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
volume(handle: clay.audio.AudioHandle, volume: Float): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
volume |
Float |
pan(handle: clay.audio.AudioHandle, pan: Float): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
pan |
Float |
pitch(handle: clay.audio.AudioHandle, pitch: Float): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
pitch |
Float |
position(handle: clay.audio.AudioHandle, time: Float): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
time |
Float |
volumeOf(handle: clay.audio.AudioHandle): Float
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Float |
panOf(handle: clay.audio.AudioHandle): Float
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Float |
pitchOf(handle: clay.audio.AudioHandle): Float
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Float |
positionOf(handle: clay.audio.AudioHandle): Float
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Float |
stateOf(handle: clay.audio.AudioHandle): clay.audio.AudioState
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
clay.audio.AudioState |
loopOf(handle: clay.audio.AudioHandle): Bool
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Bool |
instanceOf(handle: clay.audio.AudioHandle): clay.audio.AudioInstance
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
clay.audio.AudioInstance |
suspend(): Void
resume(): Void
getSoundBus(handle: clay.audio.AudioHandle): Int
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
Int |
moveSoundToBus(handle: clay.audio.AudioHandle, newBusIndex: Int): Bool
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
newBusIndex |
Int |
Returns |
---|
Bool |
Returns |
---|
Array<Int> |
Name | Type |
---|---|
busIndex |
Int |
Returns |
---|
String |
Name | Type |
---|---|
uri |
String |
busIndex |
Int |
createFunc |
Function |
destroyFunc |
Function |
addBusFilterWorklet(busIndex: Int, filterId: Int, workletClass: Class<Any>, workletReady: Function): Void
Name | Type |
---|---|
busIndex |
Int |
filterId |
Int |
workletClass |
Class<Any> |
workletReady |
Function |
Name | Type |
---|---|
busIndex |
Int |
filterId |
Int |
loadData(path: String, isStream: Bool, format: clay.audio.AudioFormat, ?async: Bool = false, ?callback: Function): clay.audio.AudioData
Name | Type | Default |
---|---|---|
path |
String | |
isStream |
Bool | |
format |
clay.audio.AudioFormat | |
async |
Bool | false |
callback |
Function | (optional) |
Returns |
---|
clay.audio.AudioData |
dataFromBytes(id: String, bytes: clay.buffers.Uint8Array, ?format: clay.audio.AudioFormat, ?callback: Function): Void
Name | Type | Default |
---|---|---|
id |
String | |
bytes |
clay.buffers.Uint8Array | |
format |
clay.audio.AudioFormat | (optional) |
callback |
Function | (optional) |
dataFromPCM(id: String, pcmData: clay.buffers.Float32Array, sampleFrames: Int, channels: Int, sampleRate: Float, ?interleaved: Bool = true, ?format: clay.audio.AudioFormat, ?callback: Function): clay.audio.AudioData
Creates AudioData from raw PCM Float32 samples.
Name | Type | Default | Description |
---|---|---|---|
id |
String | Unique identifier for this audio data | |
pcmData |
clay.buffers.Float32Array | Float32Array containing the raw PCM samples | |
sampleFrames |
Int | Number of sample frames (samples per channel) | |
channels |
Int | Number of audio channels (1 = mono, 2 = stereo, etc.) | |
sampleRate |
Float | Sample rate in Hz (e.g., 44100) | |
interleaved |
Bool | true |
Whether the PCM data is interleaved (LRLRLR...) or planar (LLL...RRR...) |
format |
clay.audio.AudioFormat | (optional) | Optional audio format information |
callback |
Function | (optional) | Optional callback when AudioData is ready |
Returns |
---|
clay.audio.AudioData |
Private Members
HALF_PI: Float
DEFAULT_BUS: Int
suspended: Bool
handleSeq: Int
instances: Map
buffers: Map
busses: Map
workletModules: Map
ignoreEndedSoundsTick0: Array<clay.web._WebAudio.WebSound>
ignoreEndedSoundsTick1: Array<clay.web._WebAudio.WebSound>
Name | Type | Default |
---|---|---|
sampleRate |
Int | 44100 |
createDefaultBus(): Void
Name | Type |
---|---|
busIndex |
Int |
soundOf(handle: clay.audio.AudioHandle): clay.web._WebAudio.WebSound
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
Returns |
---|
clay.web._WebAudio.WebSound |
getBusGainNode(busIndex: Int): js.html.audio.GainNode
Name | Type |
---|---|
busIndex |
Int |
Returns |
---|
js.html.audio.GainNode |
playBuffer(data: clay.web._WebAudio.WebAudioData): js.html.audio.AudioBufferSourceNode
Name | Type |
---|---|
data |
clay.web._WebAudio.WebAudioData |
Returns |
---|
js.html.audio.AudioBufferSourceNode |
playBufferAgain(handle: clay.audio.AudioHandle, sound: clay.web._WebAudio.WebSound, startTime: Float): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
sound |
clay.web._WebAudio.WebSound |
startTime |
Float |
playInstance(handle: clay.audio.AudioHandle, source: clay.audio.AudioSource, inst: clay.audio.AudioInstance, data: clay.web._WebAudio.WebAudioData, bufferNode: js.html.audio.AudioBufferSourceNode, volume: Float, loop: Bool, ?busIndex: Int = DEFAULT_BUS): Void
Name | Type | Default |
---|---|---|
handle |
clay.audio.AudioHandle | |
source |
clay.audio.AudioSource | |
inst |
clay.audio.AudioInstance | |
data |
clay.web._WebAudio.WebAudioData | |
bufferNode |
js.html.audio.AudioBufferSourceNode | |
volume |
Float | |
loop |
Bool | |
busIndex |
Int | DEFAULT_BUS |
stopBuffer(sound: clay.web._WebAudio.WebSound): Void
Name | Type |
---|---|
sound |
clay.web._WebAudio.WebSound |
soundEnded(sound: clay.web._WebAudio.WebSound): Void
Name | Type |
---|---|
sound |
clay.web._WebAudio.WebSound |
destroySound(sound: clay.web._WebAudio.WebSound): Void
Name | Type |
---|---|
sound |
clay.web._WebAudio.WebSound |
Name | Type |
---|---|
busIndex |
Int |
Returns |
---|
Bool |
handleSourceDestroyed(source: clay.audio.AudioSource): Void
Name | Type |
---|---|
source |
clay.audio.AudioSource |
handleInstanceDestroyed(handle: clay.audio.AudioHandle): Void
Name | Type |
---|---|
handle |
clay.audio.AudioHandle |
loadDataFromSound(path: String, format: clay.audio.AudioFormat, ?callback: Function): Void
Name | Type | Default |
---|---|---|
path |
String | |
format |
clay.audio.AudioFormat | |
callback |
Function | (optional) |
loadDataFromStream(path: String, format: clay.audio.AudioFormat, ?callback: Function): Void
Name | Type | Default |
---|---|---|
path |
String | |
format |
clay.audio.AudioFormat | |
callback |
Function | (optional) |
Name | Type |
---|---|
app |
clay.Clay |
Metadata
Name | Parameters |
---|---|
:allow |
clay.audio.AudioInstance |
:allow |
clay.audio.AudioSource |