RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Audio rework issues

Open metalgearsloth opened this issue 1 year ago • 25 comments

  • [x] InvalidValue comes up more often due to PVS stuff, I forgor about this one.
  • [ ] MidiManager needs refactoring to use more of AudioSystem and less separated as a code-path.

metalgearsloth avatar Nov 27 '23 11:11 metalgearsloth

  • FTL sound should spawn a dummy sound when the ship departs so it doesn't clip. ~~- MIDI MaxDistance is set higher than the normal sounds I think as it clips much more noticeably at MaxDistance~~
  • The occlusion raycast layer should be changed.

metalgearsloth avatar Nov 27 '23 22:11 metalgearsloth

So I did some digging. Quite a bit mostly trying to figure out the reason why global sounds are not playing for me. specifically it got me here https://github.com/space-wizards/RobustToolbox/blob/eb6f28cce088bc29730026789e3ba9f39d5177b7/Robust.Client/Audio/Sources/BaseAudioSource.cs#L175-L198 The moment that gain would be defined as 0 there is no way to change it from that point as priorGain / _gain would always be equal to NaN. I fixed it locally like this:

                AL.GetSource(SourceHandle, ALSourcef.Gain, out var priorGain);
                priorOcclusion = priorGain / _gain;
                if (Double.IsNaN(priorOcclusion)) {
                    priorOcclusion = 1f;
                }

But I'm less certain if that is me fixing it but missing the original bug. Figured I'll post my findings here for now

Uriende avatar Nov 28 '23 17:11 Uriende

Ok figured out why some other sounds work while others do not. The thing that essentially makes it so gain is fixed after being set to zero is here: https://github.com/space-wizards/RobustToolbox/blob/43138669ec3d259387be3995df03385e260a1ce9/Robust.Client/Audio/AudioSystem.cs#L357 Since it is the only other place that sets the gain of the sounds without going through the Gain setter.

Global audio never reaches that point. And so does any sound that that goes through here: https://github.com/space-wizards/RobustToolbox/blob/43138669ec3d259387be3995df03385e260a1ce9/Robust.Client/Audio/AudioSystem.cs#L306-L331 I didn't understand fully what it checks but that for example leaves the hyperspace sound muted.

Kelrak avatar Dec 11 '23 16:12 Kelrak

AFAIK it's just non-EFX platform issues and apparently MIDIs still lock contend somehow so I need to drop the update rate yet again.

metalgearsloth avatar Dec 11 '23 23:12 metalgearsloth

Can you revert https://github.com/space-wizards/RobustToolbox/pull/4680 in this case? Or do you think there's a better solution?

Kelrak avatar Dec 11 '23 23:12 Kelrak

Can you revert #4680 in this case? Or do you think there's a better solution?

0.5 isn't a good solution so I will find a better one.

metalgearsloth avatar Dec 11 '23 23:12 metalgearsloth

Cool. Let me know if you want me to test anything locally

Kelrak avatar Dec 11 '23 23:12 Kelrak

Just as a note InvalidValue seems to be a common issue still being spat out frequently.

https://discord.com/channels/310555209753690112/1178754439226593382/1184985536268599307 https://discord.com/channels/310555209753690112/790656972801572905/1184971583505309787

two examples of people seeing it.

me and pjb have also seen it happen

VasilisThePikachu avatar Dec 15 '23 00:12 VasilisThePikachu

Just as a note InvalidValue seems to be a common issue still being spat out frequently.

discord.com/channels/310555209753690112/1178754439226593382/1184985536268599307 discord.com/channels/310555209753690112/790656972801572905/1184971583505309787

two examples of people seeing it.

me and pjb have also seen it happen

Anyone have steps to repro as I did not reproduce it locally despite trying mapping changes a lot.

metalgearsloth avatar Dec 15 '23 00:12 metalgearsloth

I'll try to check tomorrow if I can reproduce it locally. Would it be possible to add to the error log from which sound is the error coming from? Might help.

Kelrak avatar Dec 15 '23 00:12 Kelrak

I'll try to check tomorrow if I can reproduce it locally. Would it be possible to add to the error log from which sound is the error coming from? Might help.

It might help knowing if it's global or PVS-related, thanks.

metalgearsloth avatar Dec 15 '23 00:12 metalgearsloth

Honestly no, the one time I saw it happen is when I was following an admin ghost going into an uninitialized grid. Idk if it was just going then in the background tho

All I know is that it happens in game somehow

VasilisThePikachu avatar Dec 15 '23 00:12 VasilisThePikachu

Tried and failed to replicate locally. My only guess now that it's related to midis.

Kelrak avatar Dec 15 '23 14:12 Kelrak

Had a local instance spam Open AL errors involving NaN Gain and such at a rate of ~400/s a couple hours ago while testing an unrelated PR.

TemporalOroboros avatar Dec 15 '23 14:12 TemporalOroboros

I made this draft figuring it might be helpful to get additional info in the logs https://github.com/space-wizards/RobustToolbox/pull/4714 since I never managed to replicate anything locally. But I'm doubtful it's the best way to do that.

Kelrak avatar Dec 15 '23 14:12 Kelrak

I just noticed that most of the errors I'm seeing get replicated on replays. I wanted to see if I can debug it but I can't get the hash to match. Can anyone point me on how I can sort that out?

Kelrak avatar Dec 17 '23 00:12 Kelrak

This is a known issue, all replays are broken for now. There's no known workaround or fix

VasilisThePikachu avatar Dec 17 '23 00:12 VasilisThePikachu

I do not get the gain issue so someone who gets it needs to send me their audio settings and reproducible steps as I'm not going to spend more time investigating something I can't reproduce.

metalgearsloth avatar Dec 18 '23 12:12 metalgearsloth

Might fix it https://github.com/space-wizards/RobustToolbox/pull/4738 but no guarantee

metalgearsloth avatar Dec 19 '23 11:12 metalgearsloth

I think all the issues I have left at the moment are the crashes (Separate issue but related to audio). But I didn't figure out a good way to replicate that yet. I'll check now to see if there are any other errors I can see

Kelrak avatar Dec 19 '23 13:12 Kelrak

This is what I still see now from time to time but not sure how to replicate or which sounds it relates to

[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Gain:212] AL error: -1, Gain is 0.10 and priorOcclusion is 1.00. EFX supported: False
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1

Kelrak avatar Dec 19 '23 13:12 Kelrak

This is what I still see now from time to time but not sure how to replicate or which sounds it relates to

[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Gain:212] AL error: -1, Gain is 0.10 and priorOcclusion is 1.00. EFX supported: False
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1
[ERRO] clyde.oal: [Playing:93] AL error: -1

Is that the first error or the last error?

metalgearsloth avatar Dec 22 '23 13:12 metalgearsloth

It's mostly a spam of this without any further context from time to time. I didn't figure out why aside from it not happening locally. I saw somewhere but can't find it now that it might be related to a limit of sources that is different on OSx

Also I didn't notice any sound issues while the errors were ongoing. Aside from once that I had to restart my game to fix some sounds.

Is there a way you can think of of creating a lot of sound sources locally? To test is that's the issue?

Kelrak avatar Dec 22 '23 13:12 Kelrak

I get this whenever I run in Release. I just tested while walking around the arrivals station and it stops when I delete light sources. Not just lights but things like vending machines, etc

IamVelcroboy avatar Dec 22 '23 16:12 IamVelcroboy

If this helps

image image image

IamVelcroboy avatar Dec 22 '23 16:12 IamVelcroboy