Audio engine improvements (WIP)

This commit is contained in:
Anuken
2025-11-06 15:37:14 -05:00
parent 11a7a41648
commit 28ba7f0bb3
4 changed files with 57 additions and 1 deletions

View File

@@ -59,6 +59,10 @@ public class SoundControl{
Events.on(ResetEvent.class, e -> {
lastPlayed = Time.millis();
//stop all in-game voices
Core.audio.soundBus.stop();
Core.audio.soundBus.play();
});
}

View File

@@ -0,0 +1,50 @@
package mindustry.audio;
import arc.*;
import arc.audio.*;
import arc.struct.*;
import mindustry.gen.*;
import static mindustry.gen.Sounds.*;
/** Sets up priorities and groups for various sounds. */
public class SoundPriority{
public static void init(){
//priority 2: long weapon loops
set(
2f,
laserbig,
beam
);
//priority 1.5: big weapon sounds, not loops
set(1.5f,
railgun
);
//priority 1: ambient noises
set(
1f,
conveyor,
smelter,
drill,
extractLoop,
flux,
hum,
respawning
);
//this is spammed a LOT
Sounds.shootBig.setMinConcurrentInterrupt(shootBig.getLength() * 0.9f);
for(var sound : Core.assets.getAll(Sound.class, new Seq<>())){
sound.setMinConcurrentInterrupt(Math.min(0.25f, sound.getLength() * 0.5f));
sound.setMaxConcurrent(7);
}
}
static void set(float value, Sound... sounds){
for(var s : sounds) s.setPriority(value);
}
}