At first thought this was an issue with mono vs stereo sounds, but tracked down the issue to Source:SetRange(). Whenever the range of a mono sound is set to 1.0 or below, it will play at full volume no matter how far away the source is from the listener.
Using a slightly modified version of the Source:SetRange lua example, the sound will play when the range is greater than 2 (which is the distance from source to listener) and when the range is equal or less than 1.0:
function App:Start()
self.window = Window:Create("Source SetRange Issue",0,0,400,300)
self.context = Context:Create(self.window)
local sound = Sound:Load("Sound/doors/fdn_door_automatic_servo_driven_close_short_05.wav")
self.source = Source:Create()
self.source:SetSound(sound)
sound:Release()
self.source:SetLoopMode(true)
self.source:Play()
self.source:SetPosition(Vec3(0,0,2))
local listener = Listener:Create()
listener:SetPosition(0,0,0)
range = 0.1
toggle = 0.005
return true
end
function App:Loop()
if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end
range = range + toggle
if range>=3 then toggle = -0.005 end
if range<=0 then toggle = 0.005 end
self.source:SetRange(range)
Time:Update()
self.context:SetColor(0,0,0)
self.context:Clear()
self.context:SetColor(1,1,1)
self.context:SetBlendMode(Blend.Alpha)
self.context:DrawText(string.format("Range: %.2f",range),0,2)
self.context:Sync(true)
return true
end