From 28ba7f0bb380af63b598b26baa9d87757b46c975 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 6 Nov 2025 15:37:14 -0500 Subject: [PATCH] Audio engine improvements (WIP) --- core/src/mindustry/ClientLauncher.java | 2 + core/src/mindustry/audio/SoundControl.java | 4 ++ core/src/mindustry/audio/SoundPriority.java | 50 +++++++++++++++++++++ gradle.properties | 2 +- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 core/src/mindustry/audio/SoundPriority.java diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index 187bcc0576..7400a45527 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -10,6 +10,7 @@ import arc.graphics.g2d.*; import arc.math.*; import arc.util.*; import mindustry.ai.*; +import mindustry.audio.*; import mindustry.core.*; import mindustry.ctype.*; import mindustry.game.EventType.*; @@ -233,6 +234,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform if(assets.update(1000 / loadingFPS)){ loader.dispose(); loader = null; + SoundPriority.init(); for(ApplicationListener listener : modules){ listener.init(); } diff --git a/core/src/mindustry/audio/SoundControl.java b/core/src/mindustry/audio/SoundControl.java index 432a3c05b6..039cacbb49 100644 --- a/core/src/mindustry/audio/SoundControl.java +++ b/core/src/mindustry/audio/SoundControl.java @@ -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(); }); } diff --git a/core/src/mindustry/audio/SoundPriority.java b/core/src/mindustry/audio/SoundPriority.java new file mode 100644 index 0000000000..a9ba725c89 --- /dev/null +++ b/core/src/mindustry/audio/SoundPriority.java @@ -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); + } +} diff --git a/gradle.properties b/gradle.properties index 6208c5dd07..e49cb65b47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=d677d2a72c +archash=f871345050