From 70ec74ebe3b1793f806d68eecc9ba860e7dab1d1 Mon Sep 17 00:00:00 2001 From: neckrat Date: Sun, 18 Jan 2026 13:53:59 +0300 Subject: [PATCH] added filters to audio:play --- lib/audio.lua | 8 +++++++- lib/spellbook.lua | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/audio.lua b/lib/audio.lua index 3e7d44c..8a3c022 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" +--- @alias SourceFilter { type: "bandpass"|"highpass"|"lowpass", volume: number, highgain: number, lowgain: number } + --- @class Audio --- @field musicVolume number --- @field soundVolume number @@ -60,7 +62,11 @@ function audio:crossfade(from, to, ms) end --- @param source love.Source -function audio:play(source) +--- @param settings SourceFilter? +function audio:play(source, settings) + if settings then + source:setFilter(settings) + end if source:getType() == "stream" then source:setLooping(self.looped) source:setVolume(self.musicVolume) diff --git a/lib/spellbook.lua b/lib/spellbook.lua index d5f8536..0c69a10 100644 --- a/lib/spellbook.lua +++ b/lib/spellbook.lua @@ -148,8 +148,14 @@ function attack:cast(caster, target) function(node) local audioPath = Tree.assets.files.audio targetSprite:animate("hurt", node) - -- Tree.assets.files.audio.sounds.hurt:play() - Tree.audio:play(audioPath.sounds.hurt) + --- @type SourceFilter + local settings = { + type = "bandpass", + volume = 1, + highgain = 0.1, + lowgain = 0.1 + } + Tree.audio:play(audioPath.sounds.hurt, settings) end } }