feature/audioengine #26

Manually merged
PeaAshMeter merged 11 commits from feature/audioengine into main 2026-01-18 17:56:13 +03:00
Showing only changes of commit ae03ee3adb - Show all commits

View File

@ -4,9 +4,10 @@ local AnimationNode = require "lib.animation_node"
--- @class Audio
--- @field musicVolume number
--- @field soundVolume number
--- @field looped boolean
--- @field animationNode AnimationNode?
--- @field from love.Source
--- @field to love.Source
--- @field from love.Source?
--- @field to love.Source?
audio = {}
audio.__index = audio
@ -14,7 +15,8 @@ audio.__index = audio
local function new(musicVolume, soundVolume)
return setmetatable({
musicVolume = musicVolume,
soundVolume = soundVolume
soundVolume = soundVolume,
looped = true
}, audio)
end
@ -40,8 +42,8 @@ end
--- @param ms number? in milliseconds
function audio:crossfade(from, to, ms)
print("[Audio]: Triggered crossfade")
self:play(to)
to:setVolume(0)
to:play()
self.from = from
self.to = to
self.animationNode = AnimationNode {
@ -60,6 +62,7 @@ end
--- @param source love.Source
function audio:play(source)
if source:getType() == "stream" then
source:setLooping(self.looped)
source:setVolume(self.musicVolume)
return source:play()
end