From 69be62bb69c8da32e19a07fd22a0fc613ef927b0 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 29 May 2022 13:48:58 +0800 Subject: [PATCH] clsSFX // FadeOut previous articulation when machine-gun-triggering. --- Source/Modules/SFX/clsSFX.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Modules/SFX/clsSFX.swift b/Source/Modules/SFX/clsSFX.swift index 77fee8f3..3fc43f7b 100644 --- a/Source/Modules/SFX/clsSFX.swift +++ b/Source/Modules/SFX/clsSFX.swift @@ -34,10 +34,16 @@ public class clsSFX: NSObject, NSSoundDelegate { private var currentBeep: NSSound? private func beep() { + let defaultVolume: Float = 0.4 // Stop existing beep if let beep = currentBeep { if beep.isPlaying { + for i in 1..<30 { + beep.volume = (defaultVolume / Float(i)) + usleep(1000) + } beep.stop() + beep.volume = defaultVolume } } // Create a new beep sound if possible @@ -54,7 +60,7 @@ public class clsSFX: NSObject, NSSoundDelegate { return } beep.delegate = self - beep.volume = 0.4 + beep.volume = defaultVolume beep.play() currentBeep = beep }