Skip to content

Features

Vurv edited this page Jun 18, 2021 · 5 revisions

Here you will find everything WebAudio can do.

Getting the current state of a stream:

local Stream = webAudio("<URL>")
print(Stream:getState() == _CHANNEL_PAUSED) # --> Will print 0 because streams start at (_CHANNEL_STOPPED aka 0)
# When this stream hits the duration of the link, it will automatically put itself in the _CHANNEL_STOPPED state.

Having streams be independent from props

You can just set the position of the stream anywhere. No props or parenting is needed.

local Stream = webAudio("<URL>")
Stream:setPos( randvec(-1000, 1000) )

Getting the current playback position of the stream

You can get the current playback position of the stream, using information provided by the client.

# Make sure to check if Stream:getLength() != -1 before doing this. If it is -1 we don't know the length yet.
local ElapsedPercentage = Stream:getTime() / Stream:getLength()

Getting a stream's FFT values

You can get the DFT (discrete Fourier transform) of a stream using xwa:getFFT().
It is an array containing _WA_FFT_SAMPLES samples of values from 0-255.
It updates every _WA_FFT_DELAY milliseconds.

local FFTs = Stream:getFFT()

Clone this wiki locally