Audio engine improvements (WIP)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
50
core/src/mindustry/audio/SoundPriority.java
Normal file
50
core/src/mindustry/audio/SoundPriority.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user