1. Anders Ruud
  2. love

Issues

Issue #643 resolved

love.audio.setOrientation and Source:setDirection don't seem to do anything

hahawoo
created an issue

Maybe this is known, it was mentioned in the forums as being due to missing functions for the cone settings.

Comments (2)

  1. Alex Szpakowski

    Added Source:setCone(innerAngle, outerAngle, outerVolume). Resolves issue #643.

    When combined with Source:setDirection (and Source:setPosition or love.audio.setPosition), the cone parameters allow for directional sound output from a Source.

    → <<cset 104bacd51395>>

  2. murks

    Was love.audio.setOrientation() ever fixed? In my experiments it did not work.

    My test code to play with it:

    local sfxr = require("lib/sfxrlua/sfxr")
    
    local xl, yl, zl = 0, 0, 0;
    local xs, ys, zs = 0, 0, 0;
    local source
    local f = 0.5
    ox, oy, oz, u1, u2, u3 = 0, 0, -1, 0, 1, 0
    
    function love.load()
        local sound = sfxr.newSound()
        sound:randomize(os.time())
        local sounddata = sound:generateSoundData()
        source = love.audio.newSource(sounddata)
        --snd = love.audio.newSource('bite_00.wav', 'static')
        source:setLooping(true);
        source:play();
    end
    
    function love.keypressed(key)
        -- Move the listener via WASD.
        if key == 'a' then
            xl = xl - f;
        elseif key == 'd' then
            xl = xl + f;
        elseif key == 'w' then
            yl = yl - f;
        elseif key == 's' then
            yl = yl + f;
        elseif key == 'r' then
            zl = zl + f;
        elseif key == 'f' then
            zl = zl - f;
       end
    
        love.audio.setPosition(xl, yl, lz);
    
    
        ox, oy, oz, u1, u2, u3 = love.audio.getOrientation()
        --orientation experiment
        if key == 'u' then
          if ox < 1 then ox=ox+1 end
        elseif key == 'j' then
          if ox > -1 then ox=ox-1 end
        elseif key == 'i' then
          if oy < 1 then oy=oy+1 end
        elseif key == 'k' then
          if oy > -1 then oy=oy-1 end
        elseif key == 'o' then
          if oz < 1 then oz=oz+1 end
        elseif key == 'l' then
          if oz > -1 then oz=oz-1 end
        end
        love.audio.setOrientation(ox, oy, oz, u1, u2, u3)
    end
    
    function love.draw()
        love.graphics.print('Listener: (xl = ' .. xl .. ', yl = ' .. yl .. ', zl = ' .. zl .. ')', 20, 40);
        love.graphics.print('Orientation: (ox = ' .. ox .. ', oy = ' .. oy .. ', oz = ' .. oz, 20, 80);
    end
    
  3. Log in to comment