has anyone got directional sounds working in LÖVE?
Positional sounds work just fine for me, but when I try to restrict the audible area of a sound with Source:setDirection and Source:setCone, these functions do not seem to have any effect.
I created the following test script where a directional sound circles the position of the listener. The sound should only be audible when the listener enters the sound's cone, but this does not happen. The sound always plays with its full volume instead.
Code: Select all
local DISTANCE = 200
local source
local angle = 0
function love.load()
local cx, cy = love.graphics.getDimensions()
love.audio.setPosition(cx / 2, cy / 2, 0)
source = love.audio.newSource("qubodup-edev.ogg", "static")
source:setVolume(0.2)
source:setLooping(true)
source:setAttenuationDistances(300, 700)
source:setDirection(1, 0, 0)
source:setCone(math.rad(10), math.rad(20), 0)
source:play()
end
function love.update(dt)
local cx, cy = love.graphics.getDimensions()
angle = angle + dt
source:setPosition(
math.cos(angle) * DISTANCE + cx / 2,
math.sin(angle) * DISTANCE + cy / 2
)
end
function love.draw()
love.graphics.setColor(1, 1, 0)
local x, y = source:getPosition()
love.graphics.circle("fill", x, y, 20)
end
Thanks and happy easter!