From b7652955b5eaa44b1e746d4ee4b86bb1dc835800 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:16:18 +0530 Subject: [PATCH] fix persisting loud sounds --- src/shapes/DuctFan.hx | 4 ++++ src/shapes/Magnet.hx | 4 ++++ src/shapes/SmallDuctFan.hx | 4 ++++ src/shapes/Tornado.hx | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/shapes/DuctFan.hx b/src/shapes/DuctFan.hx index b1ab2627..57e29c93 100644 --- a/src/shapes/DuctFan.hx +++ b/src/shapes/DuctFan.hx @@ -33,6 +33,7 @@ class DuctFan extends ForceObject { ResourceLoader.load("sound/fan_loop.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); + this.soundChannel.pause = true; onFinish(); }); }); @@ -43,5 +44,8 @@ class DuctFan extends ForceObject { var seffect = this.soundChannel.getEffect(Spatialization); seffect.position = this.getAbsPos().getPosition(); + + if (this.soundChannel.pause) + this.soundChannel.pause = false; } } diff --git a/src/shapes/Magnet.hx b/src/shapes/Magnet.hx index 8171c366..3434c749 100644 --- a/src/shapes/Magnet.hx +++ b/src/shapes/Magnet.hx @@ -34,6 +34,7 @@ class Magnet extends ForceObject { ResourceLoader.load("sound/magnet.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/magnet.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); + this.soundChannel.pause = true; onFinish(); }); }); @@ -44,5 +45,8 @@ class Magnet extends ForceObject { var seffect = this.soundChannel.getEffect(Spatialization); seffect.position = this.getAbsPos().getPosition(); + + if (this.soundChannel.pause) + this.soundChannel.pause = false; } } diff --git a/src/shapes/SmallDuctFan.hx b/src/shapes/SmallDuctFan.hx index 901382a3..adbd8401 100644 --- a/src/shapes/SmallDuctFan.hx +++ b/src/shapes/SmallDuctFan.hx @@ -33,6 +33,7 @@ class SmallDuctFan extends ForceObject { ResourceLoader.load("sound/fan_loop.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/fan_loop.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); + this.soundChannel.pause = true; onFinish(); }); }); @@ -43,5 +44,8 @@ class SmallDuctFan extends ForceObject { var seffect = this.soundChannel.getEffect(Spatialization); seffect.position = this.getAbsPos().getPosition(); + + if (this.soundChannel.pause) + this.soundChannel.pause = false; } } diff --git a/src/shapes/Tornado.hx b/src/shapes/Tornado.hx index 67a8a260..f45831fe 100644 --- a/src/shapes/Tornado.hx +++ b/src/shapes/Tornado.hx @@ -50,6 +50,7 @@ class Tornado extends ForceObject { ResourceLoader.load("sound/tornado.wav").entry.load(() -> { this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/tornado.wav", ResourceLoader.getAudio, this.soundResources), new Vector(1e8, 1e8, 1e8), true); + this.soundChannel.pause = true; for (material in this.materials) { material.blendMode = Alpha; // material.mainPass.culling = h3d.mat.Data.Face.None; @@ -64,5 +65,8 @@ class Tornado extends ForceObject { var seffect = this.soundChannel.getEffect(Spatialization); seffect.position = this.getAbsPos().getPosition(); + + if (this.soundChannel.pause) + this.soundChannel.pause = false; } }