Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bonyoze opened this issue Dec 17, 2022 · 4 comments
Labels
Complexity: Medium Something that's not as easy to implement

Comments

@Bonyoze
Copy link
Contributor

Bonyoze commented Dec 17, 2022

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):

  • OS: Windows
  • Gmod Branch: x86-64
@Bonyoze Bonyoze added the bug Something isn't working label Dec 17, 2022
@Vurv78
Copy link
Owner

Vurv78 commented Dec 17, 2022

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)

@Vurv78 Vurv78 added Complexity: Medium Something that's not as easy to implement and removed bug Something isn't working labels Dec 17, 2022
@Bonyoze
Copy link
Contributor Author

Bonyoze commented Dec 17, 2022

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
Copy link
Owner

Vurv78 commented Dec 17, 2022

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
Copy link
Owner

Vurv78 commented Dec 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Medium Something that's not as easy to implement
Projects
None yet
Development

No branches or pull requests

2 participants