RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Playing audio with MaxDistance > 1 can clip the start

Open Tayrtahn opened this issue 1 year ago • 3 comments

I'm not sure if this is just the way that the distance fadeout works, but this caused me a lot of confusion (see https://github.com/space-wizards/space-station-14/pull/36241#issuecomment-2769450437 and below).

Playing a sound file with the audio params set to have a max distance greater than 1 seems to clip off a tiny bit from the start of the file. The content file click.ogg has the important part of its content right at the start of the track: Image And this gets cut off when it is played with MaxDistance greater than 1. Adding ~10ms of silence to the beginning of the track makes it play consistently, which suggests that the beginning is getting clipped.

Tayrtahn avatar Apr 01 '25 14:04 Tayrtahn

That's... odd.

Can you breakpoint the startup method and see what the playbackoffset is? Most of the time it should be set to 0.

metalgearsloth avatar Apr 12 '25 07:04 metalgearsloth

Can confirm. This only seems to be happening with PlayPredicted, not with PlayPvs. I made FlashSystem predicted and now the flash sound is sometimes missing the first part of the click sound. To test this edit any prototype to have EmitSoundOnUse and the flash.ogg sound, where you can hear this clearly happening.

Image

https://github.com/user-attachments/assets/1a25da14-bbdd-4a5d-a348-d98acdec7ccb

slarticodefast avatar May 15 '25 14:05 slarticodefast

Can you breakpoint the startup method and see what the playbackoffset is? Most of the time it should be set to 0.

The playback offset is consistently 0 even if it gets cut off

Image

Image

slarticodefast avatar May 15 '25 15:05 slarticodefast

seems related to #6175 but IDK ive spent long enough debugging this shit for right now.

would look here as a source of the bug (i.e. it starts playing, maybe maxdistance isnt set properly, the gain gets set to 0 for a bit, then corrected later?) https://github.com/space-wizards/RobustToolbox/blob/a0ebb290e24b291e2913a480e016d2394b941a2b/Robust.Client/Audio/AudioSystem.cs#L393-L399

mirrorcult avatar Aug 29 '25 20:08 mirrorcult

okay, this is almost certainly a result of #6175 because of the position thing i found. presumably, the position is left unset as 0,0, which if you're far enough away will just make the sound not play until the next tick

mirrorcult avatar Aug 31 '25 20:08 mirrorcult