[SOLVED] source:setPosition() not panning left/right channels properly?

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
immakinggames
Prole
Posts: 22
Joined: Sat Jun 01, 2013 4:40 am

[SOLVED] source:setPosition() not panning left/right channels properly?

Post by immakinggames » Tue May 17, 2016 2:02 pm

Code: Select all

mySound:setPosition(-0.0001,0,0)
audio only comes from left speaker.

Code: Select all

mySound:setPosition(0.0001,0,0)
audio only comes from right speaker.

No matter what value I put in, anything less than zero results in sounds only coming from the left speaker and anything greater than zero results in sounds only coming from the right.

Is there no way to make it come out louder on one speaker, but still come out of the other speaker? That's what I expected setPosition to do. Changing AttenuationDistances and DistanceModels never made it possible for the sound to come out of both speakers (other than at 0) either.
Last edited by immakinggames on Tue May 17, 2016 2:13 pm, edited 1 time in total.

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: source:setPosition() not panning left/right channels properly?

Post by bartbes » Tue May 17, 2016 2:05 pm

Yes, if you move it on the y or z axes. At the moment your source is "in your head" (0, 0, 0), directly to the left of it (-0.0001, 0, 0) or directly to the right of it (0.0001, 0, 0), so the results you're getting are exactly as I'd expect. If you want to hear a source with both "ears", it also has to be offset in some other axis.

immakinggames
Prole
Posts: 22
Joined: Sat Jun 01, 2013 4:40 am

Re: source:setPosition() not panning left/right channels properly?

Post by immakinggames » Tue May 17, 2016 2:12 pm

I see, setting love.audio.setPosition(0, 1, 0) in love.load() appears to make this work properly now.

Thanks!

User avatar
pgimeno
Party member
Posts: 1979
Joined: Sun Oct 18, 2015 2:58 pm

Re: [SOLVED] source:setPosition() not panning left/right channels properly?

Post by pgimeno » Wed May 18, 2016 8:10 pm

It's not what I'd expect, and indeed I can't reproduce this issue. For me, (-0.0001, 0, 0) and (0.0001, 0, 0) sound indistinguishable, and on both channels. The right channel is attenuated more quickly than the left channel as the sound displaces left, soon becoming inaudible, and vice versa.

May that be an OpenAL version or implementation issue? (edit: this happens under Debian, libopenal1 1:1.14-1)

Here's my test program:

Code: Select all

local snd = love.audio.newSource("sound.wav")
snd:setLooping(true)
snd:play()

local onupdate = true

function love.update(dt)
  if onupdate then
    snd:setPosition((love.mouse.getX()-400)/53, 0, 0)
  end
end

function love.keypressed(k)
  if k == "escape" then love.event.quit() end
  if k == "left" then
    snd:setPosition(-0.0001, 1, 0)
  end
  if k == "right" then
    snd:setPosition(0.0001, 1, 0)
  end
  if k == "left" or k == "right" then
    onupdate = false
  elseif k == "down" then
    onupdate = true
  end
end
(only the mouse's horizontal movement is considered, or press Left for -0.0001, Right for 0.0001, and Down to return to mouse-handled)

Post Reply

Who is online

Users browsing this forum: No registered users and 100 guests