Search the Community
Showing results for tags 'source'.
Found 2 results
I have two questions regarding sound: 1. What are listeners? I can't find any documentation on what they actually are or are supposed to do. 2. Has anyone tried the firepit workshop item? It uses a source object in the code, but the farther you get away from it the volume stays the same and sounds the same no matter your position towards it (and there is no stereo effect, like if one ear is closer to the sound than the other, although this might not be implemented). I checked that it's a mono sound, so this behavior seems odd to me since the sound gets positioned at a certain point (so it should be 3D sound). Basically, it sounds like an ambient sound. What are 3D positioned sounds supposed to do?
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