Skip to content

Instantly share code, notes, and snippets.

@Vurv78
Created September 25, 2021 15:53
Show Gist options
  • Save Vurv78/44435c9f9fd53ee72c04b18cf352a096 to your computer and use it in GitHub Desktop.
Save Vurv78/44435c9f9fd53ee72c04b18cf352a096 to your computer and use it in GitHub Desktop.
WebAudio compatibility with streamcore creations using user defined functions.
@name Streamcore Replacement with WebAudio Backend
@persist WSTRCORE_TBL:table
function streamHelp() {}
function number streamCanStart() { return webAudioCanCreate() }
function entity:streamStart(Index, Url:string) {
local Wa = webAudio(Url)
Wa:setParent(This)
Wa:play()
WSTRCORE_TBL[Index, webaudio] = Wa
}
function entity:streamStart(Index, Url:string, Volume) {
local Wa = webAudio(Url)
Wa:setVolume(Volume * 100)
Wa:setParent(This)
Wa:play()
WSTRCORE_TBL[Index, webaudio] = Wa
}
function entity:streamStart(Index, Volume, Url:string) {
local Wa = webAudio(Url)
Wa:setVolume(Volume * 100)
Wa:setParent(This)
Wa:play()
WSTRCORE_TBL[Index, webaudio]:destroy() # Might not be necessary
WSTRCORE_TBL[Index, webaudio] = Wa
}
function streamStop(Index) {
local Wa = WSTRCORE_TBL[Index, webaudio]
if(Wa:isValid()) {
Wa:destroy()
}
}
function streamVolume(Index, Volume) {
local Wa = WSTRCORE_TBL[Index, webaudio]
if (Wa:isValid()){
Wa:setVolume(Volume * 100)
Wa:update()
}
}
function streamRadius(Index, Radius) {
local Wa = WSTRCORE_TBL[Index, webaudio]
if (Wa:isValid()){
Wa:setRadius(Radius)
Wa:update()
}
}
function number streamLimit() { return 0.3 }
function number streamMaxRadius() { return convarnum("wa_radius_max") }
function number streamAdminOnly() { return webAudioAdminOnly() }
function streamDisable3D(N) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment