Dynamic Surroundings

Dynamic Surroundings

51M Downloads

Problem with DS and AmbientSounds?

ShadowSonic42 opened this issue · 53 comments

commented

Mod Version:
1.10.2-3.4.7.1

Forge Version:
2477

Description:
I have AmbientSounds with DS, causing the sound to mute when I go near water with many entities swimming, that would normally cause the water bobbing sound. I have tested without AmbientSounds, and everything works without it installed. I think it might be a conflict issue between DS and AmbientSounds because I have a modpack with both of them installed, and other mod sounds are working, except for DS. I have also tested with just DS and AmbientSounds, that is when the issue happens.
Example vid of AmbientSounds and DS
Example vid of just DS

commented

Hey man, did you mange to find a way fixing your problem?
I got similar issue that in-game music don't play (like ever), possibly due to AS and DS taking up streaming channel always?
Maybe I should increasing the number of channels signed to streaming and test a bit .

commented

FYI - I am going to be doing some testing with Ambient Sounds and DS this week. I will see if it still occurs with the latest mod versions.

commented

@CreativeMD

OK. Loaded up the latest of both DS and Ambient Sounds. DS initializes the sound channels within the SoundSetupEvent Forge fires. It configures the channels to what DS wants. Later on, AmbientSounds sets the channels in its FMLInitializationEvent handler. The decompiled codes shows it is setting the streaming/normal channels to 11/21 respectively overriding what DS is doing. The values that AmbientSounds are using appear to be hard coded based on what I see in the JAR.

My recommendation is for AmbientSounds to configure the sound channels in response to the SoundSetupEvent (at a priority higher than LOWEST since DS is registered there). This will allow DS to override whatever AmbientSounds want and I think everything will be happy.

commented

@OreCruncher sorry, i completely forgot to answer.
We talked about this before. AmbientSounds requires more streaming channels per default, so it's overwriting the changes of DS (otherwise the mods could not run alongside each other without further configuration). You can configure the number of channels in the config file (at least in the newer versions).

commented

The source I looked at was from github and the JAR came from CurseForge. DS sets 16 streaming channels, and AS sets 11. :)

commented
commented

I think this stomps on that: https://github.com/CreativeMD/AmbientSounds/blob/1.12/src/main/java/com/creativemd/ambientsounds/AmbientSounds.java#L73

The load event fires after sound config. So it looks like Ambient Sounds sets, DS then sets, and then Ambient Sounds resets back. Could be the source of the config issue mentioned above.

commented

Oh right, those don't matter, they are fired during startup. I forgot to remove them.

commented

Hello! I see this thread is still active, have you find any solution yet ^^?

I don't know if I have the same problem, but it seems like when I have the two mods installed, sometimes the sounds from DS just stops for a moment (ex: I don't hear my footsteps for a few seconds, then I hear them again)...

Thank you!

commented

I'm pretty sure we know the issue. The sounds of DS stopping is because DS does sound throttling - if the number of sounds down in the sound engine is near the maximum number of channels it won't play a sound. Currently waiting on a code adjustment for AS. :)

commented

You can configure the number of channels in AmbientSounds, but i'm not sure whether this will fix this issue or not. The sound engine only allows 32 channels at the same time. If there are not enough channels available (too many sounds are played at the same time) a sound will not be played.

commented

The bug is still in the code on Github. Modern computers have sound cards that support up to 256 channels. It's why I have that check down in the sound config of DS.

commented

@OreCruncher it doesn't matter, it doesn't change anything at all.
@xhatz you can try to increase the number of channels, maybe this fixes the issue (if orecruncher is right you can set more channels than 32).

commented

@CreativeMD That's weird. I tweaked DS to redo the sound channel config during my init phase after AS init phase runs (the code link above) and I get the proper number of sound channels DS expects.

commented

Yes. but AS changes the number of channels before the sound engine will be started: https://github.com/CreativeMD/AmbientSounds/blob/1.12/src/main/java/com/creativemd/ambientsounds/TickHandler.java#L258

EDIT
I can also remove it, if you want to as DS is using more streaming channels than before (which caused a couple of issues).

commented

@CreativeMD AS actually sets the sound channels twice - once in the event, and then again in your init phase. During startup the event fires before the init phase. So the ordering of what is happening is:

SetupEvent -> AS configs channels (11/32)
SetupEvent -> DS configs channels (16/192) overriding what AS event handler did
Init phase -> AS sets the sound channels back to (11/32), overriding what DS did and whatever the user may have configured in the AS config file.

The change I just committed to DS will re-re-configure the sound channels during the DS init phase, which sets the sound channels back to what DS exepects.

commented

@OreCruncher oh ... i will release a fix for it right away. I thought the SetupEvent would be called after the init phase :D my bad sorry.

commented

No worries. I am sure that in MC 1.13 the startup sequence will change again. :D

commented

Uploaded it, the new version should be available soon.

commented

I did check the latest with DS and AS and things work well. Closing out. Thanks!

commented

DS has built in some logic that detects when the max number of sounds are queued up in the sound engine and does not play further sounds until there is room. With all that sound occuring it could be that max sounds have been reached.

To check you can turn on debug logging in DS, and then hit F3 when hear the water where all the mobs are located. DS enumerates all the sounds that are playing in the debug display along with their counts. IIRC the threshold for "self muting" is about 176 sounds or so.

commented

So how would I go about fixing the problem?

commented

Well, in this particular case you can tag the bubble sound to be culled. It will reduce the frequency that the sound will play. This assumes, of course, the situation I outline above is what is happening.

commented

After playing for a bit longer, this happened.

commented

I see that the max number of sounds is 32. You change the configuration any? If not I will need a client log - there is a mod conflict somewhere.

EDIT: I recall that ambient sounds also sets the number of sound channels. It may be reducing it from what DS sets it to. Don't recall if Ambient Sounds has a config for it - may want to look.

commented

From what I can tell, the config for Ambient Sounds only is for enabling or disabling sounds and a debugging option, nothing else. Log

commented

@ShadowSonic42 Try out this test jar located here. I changed how the sound system is initialized so it should help.

commented

I have tested with the new jar, and I still have the same results.
Results with AS
Results with only DS

commented

@CreativeMD At this point, then, I would think a change would have to be made in Ambient Sounds.

EDIT: @ShadowSonic42 Can you post a link to your client log for when both AS and DS are running together? There may be some other info in there.

commented
[10:33:58] [Client thread/INFO] [dsurround/]: Sound channels: 176 normal, 16 streaming (total avail: 192)
[10:33:58] [Client thread/INFO] [dsurround/]: Stream buffers: 3 x 131072

My mod set the channels the way it expects. I suspect that AS is changing them back at some point after.

commented

DS is setting the amount of channels, then AS later changes them? If that is the case, is there a way to make it so AS loads first then DS overrides that?

commented

Its not a question of mod loading, its a question as to when what code runs. DS sets the number of channels after the normal sound setup event. I believe the AS code is executing sometime after that under some other conditions. I haven't had a chance to trace actual execution in my debug environment.

commented

Made another tweak to see if I can alter the flow. Find it here.

commented

Tested the new version, and sadly still same results.
Results

[EDIT] I forgot to mention, now there is a new problem where some DS sounds don't even play (without AS).

commented

I have done some more tests on the second issue, and it seems to be with sound physics. The sounds do play, they are just very quiet.
DS v3.4.7.2T4 and soundphysics (you may need to turn up the volume to hear this one)
DS v3.4.7.1 and soundphysics
These clips don't have AS installed, this is just another issue that I found while playing around with compatible mods. (AS and DS compatibility issue does still happen in both versions)

commented

So I did another test to see if I could change the max amount of sounds that could play at once. By what you said earlier, I would assume that the sound system was not meant to be a max of 32 sounds. So I went ahead and disabled Ambient Sounds to see if that number would change. The max after that was 192 sounds. Then is the problem with DS not working with Ambient Sounds, or the other way around?

commented

Default vanilla configures the sound engine to a max of 32 sounds. Dynamic Surroundings ups it to some fraction of the max sound channels for the players hardware. (Modern sound systems allow on average 256 sound channels.) Ambient Sounds configures the number of sound channels as well and looks to be overriding what DS sets. Ideally Ambient Sounds should allow for tuning these values rather than hard coding them.

commented

So there is no way for me, nor you, to be able to fix this unless the developer for Ambient Sounds allows for the amount of channels to be changed?

commented

At the moment I can't think of anything you can do to make it work. I will have to think on what I could do on my end to work around it.

commented

@OreCruncher The sound engine has 4 streaming channels per default , which is not enough for AmbientSounds, so i changed it (forum thread). Once I found that DS does change those values as well, I added @SubscribeEvent(priority = EventPriority.LOW) to my method, so my configuration will be set after yours. Otherwise there would have been many issues if DS is installed (would ruin compatibility).

@ShadowSonic42 I added a config option for streaming and normal channels count (versions should be available soon). Hope this fixes this issue.

commented

From what I recall Sound Physics does funky things with sound volumes. In general I say its not compatible. I personally use Sound Filters.

commented

@CreativeMD I have updated AS to the lastest version, v2.0.8, and I also changed the config. I have set the normal and streaming channels to the values that DS, v3.4.7.2, would have set them to.
AS config

But, I got the same results as before I updated.
Look at the soundsystem on the side

commented

The sound engine configuration says that they may only be 32 channels in total. So maybe you don't have 176 normal channels, but 16. Just try to use less streaming channels and see if this fixes it.

commented

I think his system has more than 32. I looked at a provided log and based on the trace it appears to have 256 channels for the system.

commented

@CreativeMD I changed the values to be lower than 32 to see if the config is working, or my system wasn't powerful enough.
New Config

As you can see, the total amount of channels should be less than 32.
But that didn't change the value

commented

@ShadowSonic42 Not less than 32, but 32 in total meaning something like: 8 streaming channels and 24 normal channels for example.

commented

But if I changed the values to be less than 32, shouldn't they change to that instead?

EDIT: To clarify my question, if I set the value to add up to a total of, for example, 16 total channels. (12 normal, 4 streaming). Would the total amount of sound channels change from 32 to 16 or stay the same?

commented

If you only have 32 channels available and set 16 streaming channels. There are only 16 channels left. Setting the config to 16 normal channels will not change anything either, since the engine can also have less than 32 channels. So just increase this number to 24 and see if something changes.

In my eyes it's rather obvious that this issue is caused by a lack of available normal channels, so increasing those should fix it. You could also try out the vanilla configuration, of 4 streaming and 28 normal channels.

commented

@CreativeMD Problem still exists with 24 normal channels and 8 streaming (your recommended)
DS sounds aren't playing when many sounds are in the area

And problem still exists with 28 normal channels and 4 streaming (default)
Same result as above

But without AS installed the issue goes away and I have 176 normal and 16 streaming (DS settings)
Total amount of sounds on left side

But as you saw earlier, changing the amount of channels in the config to be more than 32, did not change it to that value, which could be the problem.

commented

That is weird, but i don't think there is any way for me to fix it. I think those are just the limit of the sounds engine :(

commented

@CreativeMD Maybe you could ask @OreCruncher on what he did with DS or figure out how to make it so DS algorithm is prioritized over AS. IDK just a suggestion.

commented

I'm sorry to disappoint you, but i doubt that there is an easy way to fix it.