added filters to audio:play

This commit is contained in:
neckrat 2026-01-18 13:53:59 +03:00
parent ae03ee3adb
commit 70ec74ebe3
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,8 @@
local ease = require "lib.utils.easing" local ease = require "lib.utils.easing"
local AnimationNode = require "lib.animation_node" local AnimationNode = require "lib.animation_node"
--- @alias SourceFilter { type: "bandpass"|"highpass"|"lowpass", volume: number, highgain: number, lowgain: number }
--- @class Audio --- @class Audio
--- @field musicVolume number --- @field musicVolume number
--- @field soundVolume number --- @field soundVolume number
@ -60,7 +62,11 @@ function audio:crossfade(from, to, ms)
end end
--- @param source love.Source --- @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 if source:getType() == "stream" then
source:setLooping(self.looped) source:setLooping(self.looped)
source:setVolume(self.musicVolume) source:setVolume(self.musicVolume)

View File

@ -148,8 +148,14 @@ function attack:cast(caster, target)
function(node) function(node)
local audioPath = Tree.assets.files.audio local audioPath = Tree.assets.files.audio
targetSprite:animate("hurt", node) targetSprite:animate("hurt", node)
-- Tree.assets.files.audio.sounds.hurt:play() --- @type SourceFilter
Tree.audio:play(audioPath.sounds.hurt) local settings = {
type = "bandpass",
volume = 1,
highgain = 0.1,
lowgain = 0.1
}
Tree.audio:play(audioPath.sounds.hurt, settings)
end end
} }
} }