CrazyM Posted September 26, 2014 Share Posted September 26, 2014 Doe anyone know if you can stop a looping Entity:EmitSound() method without releasing the entity, then start the sound again back in loop mode? It looks like EmitSound automatically creates a Source and the entity manages it. Is there some way to get reference to this Source to call Source:Stop()? EDIT: Nevermind, I'll just create and manage the Source manually. Quote CrazyMinnowStudio.com Youtube, Twitter, Facebook, G+ Link to comment Share on other sites More sharing options...
macklebee Posted September 26, 2014 Share Posted September 26, 2014 In LE2's lua, the source was the entity emitting the sound as the command would return a TSource source = box:EmitSound(sound,5,1) unfortunately, it appears that no longer works... sounds like a good thing to bring up in the suggestions... or at least a need for an entity:GetSource() command 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...
Ma-Shell Posted September 26, 2014 Share Posted September 26, 2014 In C++ you can do emitter->EmitSound(snd); Source* s = emitter->activesources.front(); with emitter being an Entity and snd a Sound. Surely this isn't the cleanest way. I agree, it would be nice to have the actual Source returned by the Emit-Call. 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 26, 2014 Share Posted September 26, 2014 unfortunately we dont have access to that in lua but hopefully Josh will see the post and see the need to add this 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...
Josh Posted September 26, 2014 Share Posted September 26, 2014 The reason for this design is returning a source would require the user to release it. This would likely cause more problems then it solves. What about a new overload that accepts a source as an argument? This would allow you to retain control of the source and remain simple to use. The only thing this adds is that the source will automatically have its position updated when the entity moves. 3 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 September 26, 2014 Share Posted September 26, 2014 What about a new overload that accepts a source as an argument? This would allow you to retain control of the source and remain simple to use. The only thing this adds is that the source will automatically have its position updated when the entity moves. so something like static Model* Load(const std::string& path, int flags=0, const uint64_t fileid=0, Source *source=null)? or would it be easier to have something like entity:SetSource() / entity:GetSource()? granted your way would solve the problem as long as all the available model entities have this overload... and it would basically remove the need for EmitSound() 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...
Ma-Shell Posted September 26, 2014 Share Posted September 26, 2014 The reason for this design is returning a source would require the user to release it. If there was only a pointer returned, that would not be the case. IMHO the most logical way to do that would be: A pointer to the created source is returned but the refcounter is not increased. If the user wants to keep the reference, he can increase its refcounter (src->AddRef()), so it would not be automatically removed, when it finished playing (the refcount would only be decreased by 1 (Currently it isn't even possible to keep the reference any further due to the bug I reported here: http://www.leadwerks.com/werkspace/topic/10804-finished-sound-sources-are-released-every-frame/)). If the user does not add a reference, the source will be removed once it finished and the user might end up with a corrupt reference, but that would be the user's own fault. 1 Quote Link to comment Share on other sites More sharing options...
CrazyM Posted September 27, 2014 Author Share Posted September 27, 2014 Wow, active discussion in my absence...LOL! I don't find the manually managed source route a bad option and am somewhat ambivalent. It would be nice to simply get a reference from EmitSound and have it's position updates already handled, but it's not really a big deal either way (to me anyway) now that I understand how it works. Quote CrazyMinnowStudio.com Youtube, Twitter, Facebook, G+ 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.