Directional sounds not working

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
BurrickSlayer
Prole
Posts: 15
Joined: Sat Dec 21, 2013 4:28 pm

Directional sounds not working

Post by BurrickSlayer »

Hi all,

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
Am I doing anything wrong here?

Thanks and happy easter!
User avatar
pgimeno
Party member
Posts: 3582
Joined: Sun Oct 18, 2015 2:58 pm

Re: Directional sounds not working

Post by pgimeno »

Works for me. Maybe a problem with your sound driver or OpenAL library?
BurrickSlayer
Prole
Posts: 15
Joined: Sat Dec 21, 2013 4:28 pm

Re: Directional sounds not working

Post by BurrickSlayer »

Thank you for trying this out!

Interesting, I wonder if it might be related to macOS which has some version of OpenAL pre-installed. I will try this on another Mac system and see if it works there.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests