diff --git a/core/assets/sounds/loops/loopBuild.ogg b/core/assets/sounds/loops/loopBuild.ogg index 67361d4eec..1718d3637d 100644 Binary files a/core/assets/sounds/loops/loopBuild.ogg and b/core/assets/sounds/loops/loopBuild.ogg differ diff --git a/core/assets/sounds/loops/loopDifferential.ogg b/core/assets/sounds/loops/loopDifferential.ogg index 0e6566475b..8318a59de0 100644 Binary files a/core/assets/sounds/loops/loopDifferential.ogg and b/core/assets/sounds/loops/loopDifferential.ogg differ diff --git a/core/assets/sounds/loops/loopHover.ogg b/core/assets/sounds/loops/loopHover.ogg index 22904dd0d7..e291d1bc33 100644 Binary files a/core/assets/sounds/loops/loopHover.ogg and b/core/assets/sounds/loops/loopHover.ogg differ diff --git a/core/assets/sounds/loops/loopHover2.ogg b/core/assets/sounds/loops/loopHover2.ogg new file mode 100644 index 0000000000..0848df3b32 Binary files /dev/null and b/core/assets/sounds/loops/loopHover2.ogg differ diff --git a/core/assets/sounds/movement/mechStepSmall.ogg b/core/assets/sounds/movement/mechStepSmall.ogg index 5cefc03b5b..1a91fc7d11 100644 Binary files a/core/assets/sounds/movement/mechStepSmall.ogg and b/core/assets/sounds/movement/mechStepSmall.ogg differ diff --git a/core/assets/sounds/movement/walkerStepSmall.ogg b/core/assets/sounds/movement/walkerStepSmall.ogg index bbd16aaec9..3c63c64222 100644 Binary files a/core/assets/sounds/movement/walkerStepSmall.ogg and b/core/assets/sounds/movement/walkerStepSmall.ogg differ diff --git a/core/src/mindustry/audio/SoundControl.java b/core/src/mindustry/audio/SoundControl.java index 039cacbb49..b51348a23d 100644 --- a/core/src/mindustry/audio/SoundControl.java +++ b/core/src/mindustry/audio/SoundControl.java @@ -96,15 +96,21 @@ public class SoundControl{ } public void loop(Sound sound, Position pos, float volume){ - if(Vars.headless) return; + loop(sound, pos, volume, 1f); + } + + public void loop(Sound sound, Position pos, float volume, float pitch){ + if(Vars.headless || sound == Sounds.none || volume <= 0.00001f) return; float baseVol = sound.calcFalloff(pos.getX(), pos.getY()); float vol = baseVol * volume; SoundData data = sounds.get(sound, SoundData::new); data.volume += vol; + data.pitch += pitch * vol; data.volume = Mathf.clamp(data.volume, 0f, 1f); data.total += baseVol; + data.totalVolume += vol; data.sum.add(pos.getX() * baseVol, pos.getY() * baseVol); } @@ -198,9 +204,10 @@ public class SoundControl{ boolean play = data.curVolume > 0.01f; float pan = Mathf.zero(data.total, 0.0001f) ? 0f : sound.calcPan(data.sum.x / data.total, data.sum.y / data.total); + float pitch = Mathf.zero(data.totalVolume, 0.0001f) ? 1f : data.pitch / data.totalVolume; if(data.soundID <= 0 || !Core.audio.isPlaying(data.soundID)){ if(play){ - data.soundID = sound.loop(data.curVolume, 1f, pan); + data.soundID = sound.loop(data.curVolume, pitch, pan); Core.audio.protect(data.soundID, true); } }else{ @@ -210,10 +217,15 @@ public class SoundControl{ return; } Core.audio.set(data.soundID, pan, data.curVolume); + if(!Mathf.equal(pitch, 1f, 0.001f)){ + Core.audio.setPitch(data.soundID, pitch); + } } + data.pitch = 0f; data.volume = 0f; data.total = 0f; + data.totalVolume = 0f; data.sum.setZero(); }); } @@ -323,11 +335,11 @@ public class SoundControl{ } protected static class SoundData{ - float volume; + float volume, pitch; float total; Vec2 sum = new Vec2(); int soundID; - float curVolume; + float curVolume, totalVolume; } } diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index c1117d1c7e..6bd37501e7 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -681,7 +681,7 @@ public class UnitTypes{ stepSound = Sounds.walkerStepSmall; stepSoundPitch = 1f; - stepSoundVolume = 0.2f; + stepSoundVolume = 0.25f; legCount = 4; legLength = 9f; @@ -1037,6 +1037,11 @@ public class UnitTypes{ circleTargetRadius = 60f; wreckSoundVolume = 0.7f; + moveSound = Sounds.loopThruster; + moveSoundPitchMin = 0.3f; + moveSoundPitchMax = 1.5f; + moveSoundVolume = 0.2f; + weapons.add(new Weapon(){{ y = 1f; x = 0f; @@ -1062,7 +1067,7 @@ public class UnitTypes{ health = 340; speed = 1.65f; accel = 0.08f; - drag = 0.016f; + drag = 0.03f; flying = true; hitSize = 11f; targetAir = false; @@ -1079,6 +1084,10 @@ public class UnitTypes{ rotateSpeed = 4.5f; circleTargetRadius = 40f; + moveSound = Sounds.loopThruster; + moveSoundPitchMin = 0.6f; + moveSoundVolume = 0.4f; + weapons.add(new Weapon(){{ minShootVelocity = 1f; x = 3f; @@ -2599,7 +2608,7 @@ public class UnitTypes{ treadRects = new Rect[]{new Rect(12 - 32f, 7 - 32f, 14, 51)}; researchCostMultiplier = 0f; - tankMoveVolume *= 0.6f; + tankMoveVolume *= 0.32f; tankMoveSound = Sounds.tankMoveSmall; weapons.add(new Weapon("stell-weapon"){{ @@ -2645,7 +2654,7 @@ public class UnitTypes{ treadRects = new Rect[]{new Rect(17 - 96f/2f, 10 - 96f/2f, 19, 76)}; researchCostMultiplier = 0f; - tankMoveVolume *= 0.75f; + tankMoveVolume *= 0.55f; tankMoveSound = Sounds.tankMove; weapons.add(new Weapon("locus-weapon"){{ @@ -3729,6 +3738,10 @@ public class UnitTypes{ itemCapacity = 0; useEngineElevation = false; researchCostMultiplier = 0f; + moveSound = Sounds.loopExtract; + moveSoundVolume = 0.25f; + moveSoundPitchMin = 0.7f; + moveSoundPitchMax = 1.5f; abilities.add(new MoveEffectAbility(0f, -7f, Pal.sapBulletBack, Fx.missileTrailShort, 4f){{ teamColor = true; diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index f747ab9cb3..950e32fa6b 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -707,8 +707,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I kill(); } - if(!headless && type.loopSound != Sounds.none){ + if(!headless){ control.sound.loop(type.loopSound, this, type.loopSoundVolume); + if(type.moveSound != Sounds.none){ + float progress = Mathf.clamp(vel.len() / type.speed); + float pitch = Mathf.lerp(type.moveSoundPitchMin, type.moveSoundPitchMax, progress); + control.sound.loop(type.moveSound, this, type.moveSoundVolume * progress, pitch); + } } //check if environment is unsupported diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 87c0efd12c..010a7c0268 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -314,6 +314,12 @@ public class UnitType extends UnlockableContent implements Senseable{ public float stepSoundPitch = 1f, stepSoundPitchRange = 0.1f; /** sound looped when tank moves */ public Sound tankMoveSound = Sounds.tankMove; + /** sound looped when the unit moves; volume depends on velocity */ + public Sound moveSound = Sounds.none; + /** volume of movement sound */ + public float moveSoundVolume = 1f; + /** pitch of movement sound based on velocity */ + public float moveSoundPitchMin = 1f, moveSoundPitchMax = 1f; /** volume of tank move sfx */ public float tankMoveVolume = 0.5f; /** effect that this unit emits when falling */