From a4e2a2f2574e59c13b06ffb660362e8a110229f9 Mon Sep 17 00:00:00 2001 From: PeaAshMeter Date: Mon, 19 Jan 2026 00:45:04 +0300 Subject: [PATCH] Improve audio effects handling and update spell sound filter type --- lib/audio.lua | 21 ++++++++++++--------- lib/spellbook.lua | 3 +-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/audio.lua b/lib/audio.lua index eaa7652..a480272 100644 --- a/lib/audio.lua +++ b/lib/audio.lua @@ -1,6 +1,8 @@ local ease = require "lib.utils.easing" local AnimationNode = require "lib.animation_node" +local EFFECTS_SUPPORTED = love.audio.isEffectsSupported() + --- @alias SourceFilter { type: "bandpass"|"highpass"|"lowpass", volume: number, highgain: number, lowgain: number } --- @class Audio @@ -62,19 +64,20 @@ end --- @param settings SourceFilter? --- @param effectName string? function audio:play(source, settings, effectName) - if settings then - source:setFilter(settings) - end - if effectName then - source:setEffect(effectName, true) - end if source:getType() == "stream" then source:setLooping(self.looped) source:setVolume(self.musicVolume) - return source:play() + source:play() + else + source:setVolume(self.soundVolume) + source:play() + end + if settings and EFFECTS_SUPPORTED then + source.setFilter(source, settings) + end + if effectName and EFFECTS_SUPPORTED then + source:setEffect(effectName, true) end - source:setVolume(self.soundVolume) - return source:play() end function audio:setMusicVolume(volume) diff --git a/lib/spellbook.lua b/lib/spellbook.lua index e328371..a2e5608 100644 --- a/lib/spellbook.lua +++ b/lib/spellbook.lua @@ -172,9 +172,8 @@ function attack:cast(caster, target) targetSprite:animate("hurt", node) --- @type SourceFilter local settings = { - type = "bandpass", + type = "highpass", volume = 1, - highgain = 0.1, lowgain = 0.1 } Tree.audio:play(audioPath.sounds.hurt, settings)