Vurv78 / WebAudio

A safe, efficient and powerful replacement for Streamcore that adds playing & manipulating URL streams through IGmodAudioChannel/BASS
https://steamcommunity.com/sharedfiles/filedetails/?id=2466875474
MIT License
18 stars 3 forks source link

webaudio:set3DEnabled does not actually change the "3d" flag in sound.PlayURL #63

Open Bonyoze opened 1 year ago

Bonyoze commented 1 year ago

Describe the bug Playing an audio file that doesn't support 3D will still result in BASS_ERROR_NO3D despite disabling it webaudio:set3DEnabled(0). This is due to the bug where BASS cannot play AAC codec streams in 3D [https://github.com/Facepunch/garrysmod-issues/issues/2296](). This is a shame because Youtube uses AAC codec streams and thus isn't directly playable with WebAudio. Streamcore fixes this and it isn't at all an issue (read end of expected behavior).

To Reproduce Paste down the following code in Expression 2 (The audio was fetched directly from Youtube, but I've downloaded it and put it on Dropbox since Youtube expires the raw audio link after a while)

if (first()) {
    local Url = "https://dl.dropboxusercontent.com/s/olo98rrd1c3w5t4/videoplayback.weba"
    local Audio = webAudio(Url)
    Audio:set3DEnabled(0)
    Audio:setParent(entity())
    Audio:play()
}

Then open console and you should see the following error: [WA]: Error when creating WebAudio receiver with id n, Error [BASS_ERROR_NO3D]

Expected behavior WebAudio should remove the "3d" flag when calling sound.PlayURL if 3D is not enabled. Currently, WebAudio just sets the sound's position on top of the player to mimic 2D which is weird considering removing the "3d" flag would already accomplish the effect. The volume of the 2D sound would just have to be set to 0 when the client leaves the listening radius. Streamcore does something similar by lowering the volume the farther the client is from the sound.

Desktop (please complete the following information):

Vurv78 commented 1 year ago

This is because it directly maps to IGmodAudioChannel:Set3dEnabled.

The reason why this hasn't been done is because it'd involve creating the object asynchronously, or would have to be done in the actual webAudio constructor because that's where the object is transmitted to be created on the client

I mean all that needs to be done is adding constants for bass flags and then adding it to the constructor if you someone wants to do it, maybe I'll get to it eventually

webAudio("", _WA_FLAG_3D)

Bonyoze commented 1 year ago

It could be setup so it's always 2D and then 3D is simulated by adjusting the volume depending on the client's distance to the sound. Having 3D disabled would just mean not adjusting the volume.

I'm unsure however if updating the volume too often is a great idea.

Vurv78 commented 1 year ago

Yeah I thought of that but you'd need to support all of the modifiers to set direction and stuff, would get complicated pretty quickly

Vurv78 commented 1 year ago

I think it would be the best way to go but It's a quite the undertaking I don't really want to start right now