Jump to content

sound 3d spatialization


drarem
 Share

Recommended Posts

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)

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

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.

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

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)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...