drarem Posted June 7, 2016 Share Posted June 7, 2016 Ok, only mono sounds can be played using 3d spatialization. are there any examples for it, or is it automatic as long as the sound is mono format? Quote Link to comment Share on other sites More sharing options...
Josh Posted June 7, 2016 Share Posted June 7, 2016 http://www.leadwerks.com/werkspace/page/api-reference/_/source/sourcesetposition-r323 Note that emitting a sound from an entity may be the easiest way to manage this, but the sound source class gives you more control. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
drarem Posted June 7, 2016 Author Share Posted June 7, 2016 Ok I found this, but the documenation I think lies if i read it right.. loop=false doesn't let it keep playing. once the entity is released, the sound doesn't get a chance to play. It is killed with the entity. self.entity:EmitSound(self.sound.glassbreak, 40, 1, 1, false) Quote Link to comment Share on other sites More sharing options...
Josh Posted June 7, 2016 Share Posted June 7, 2016 Right, use a sound source if you don't want it associated with an entity. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
drarem Posted June 8, 2016 Author Share Posted June 8, 2016 I set up the source sound looking at the api, i know my audio is a mono (1 track), but when it plays, it doesn't sound like it's in the distance on the more distant ones. Am i missing something else? Thanks. Start: self.sound={} self.sound.glassbreak=Sound:Load(self.glassbreak) --Create a self.source self.source = Source:Create() self.source:SetSound(self.sound.glassbreak) self.sound.glassbreak:Release() self.source:SetLoopMode(false) self.source:SetRange(60.0) end -- play this audio once when the glass breaks self.source:SetPosition(self.entity:GetPosition()) self.source:Play() self.entity:SetMass(0) self.entity:SetCollisionType(0) self.entity:Release() Quote Link to comment Share on other sites More sharing options...
Josh Posted June 8, 2016 Share Posted June 8, 2016 That should be all it takes. Do you have a listener in the world? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
drarem Posted June 8, 2016 Author Share Posted June 8, 2016 I tried creating a local listener for the self releasing object in the Start() function as in the API example showed, didn't seem to help Quote Link to comment Share on other sites More sharing options...
Josh Posted June 8, 2016 Share Posted June 8, 2016 Your sound is probably not mono. Take one of the provided samples, replace it with your sound, and make sure it works. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted June 8, 2016 Share Posted June 8, 2016 simple example that you can use to test your mono sound with: window = Window:Create("Source",0,0,400,300,16) context = Context:Create(window) world = World:Create() light = DirectionalLight:Create() camera = Camera:Create() box = Model:Box() box:SetColor(1,.5,0,1) box:SetPosition(0,0,5) sound = Sound:Load("Sound/doors/fdn_door_automatic_servo_driven_close_short_05.wav") source = Source:Create() source:SetSound(sound) sound:Release() source:SetLoopMode(true) source:SetRange(15) source:Play() toggle = 1 while window:KeyHit(Key.Escape)==false do if window:Closed() then break end box:Turn(.5,.5,0) if box:GetPosition().z > 20 then toggle = -1 elseif box:GetPosition().z < 3 then toggle = 1 end box:Translate(0,0,0.03*Time:GetSpeed()*toggle) source:SetPosition(box:GetPosition()) Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:DrawText("Position: "..box:GetPosition():ToString(),0,2) context:Sync(true) end It could be with the range being that high (60m) that its difficult for you to tell the difference in volume when you are 55m versus say 50m away? Whereas if the range was say only 25m, you could definitely tell the difference between 20m and 15m away. I am assuming that the volume is interpolated across the range. So moving 55m to 50m away (with 60m range) is only ~8.3% change in volume but moving 20m to 15m away (with 25m range) is a 20% change in volume. In both cases you only moved 5 meters, but had significantly different volume changes. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
drarem Posted June 8, 2016 Author Share Posted June 8, 2016 tried adding listener back, am using another mono sample. This is in the start function, but should it get moved to where the entity is instead of at 0,0,0 ? Thanks. --Create a listener local listener = Listener:Create() listener:SetPosition(0,0,0) Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 8, 2016 Share Posted June 8, 2016 The listener should be positioned wherever the player/camera/entity that should hear the sound is located. If you position the listener at (0,0,0), then it will report sounds based on hearing from that location Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
drarem Posted June 8, 2016 Author Share Posted June 8, 2016 Dropping the range made the difference, thank you. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.