local love = love
local sfx = {}

love.audio.setDistanceModel( "linear" )

local footsteps = {}
for i, file in pairs( love.filesystem.getDirectoryItems( "sfx/footsteps" ) ) do
  footsteps[i] = love.audio.newSource( "sfx/footsteps/"..file, "static" )
  footsteps[i]:setVolume( 0.02 )
end

local stepIdx = 1
function sfx.playFootstep()
  footsteps[ stepIdx ]:stop()
  stepIdx = math.random( 1, #footsteps )
  footsteps[ stepIdx ]:play()
end

function sfx.setPosition( x, y, z )
  return love.audio.setPosition( x, y, z )
end

function sfx.setOrientation( yaw )
  local x, z = math.cos( yaw ), math.sin( yaw )
  return love.audio.setOrientation( x, 0, z, 0, 1, 0 )
end

return sfx