SFXPlayOnce vs SFXPlay
by Novack · in Torque Game Engine Advanced · 07/30/2009 (5:08 pm) · 5 replies
Could someone explain to me the difference between SFXPlayOnce() and SFXPlay()?
My supposition is that the this call will ignore the information within the SFXDescription for "MyProfile" (like the isLooping field), and just play it once:
On the other side, I guess that this will respect the info declared in the SFXProfile and SFXDescription:
Nonetheless, those suppositions feel rather weak, and couldn't find info about it.
My supposition is that the this call will ignore the information within the SFXDescription for "MyProfile" (like the isLooping field), and just play it once:
%source = SFXPlayOnce( MyProfile );
On the other side, I guess that this will respect the info declared in the SFXProfile and SFXDescription:
%source = SFXPlay( MyProfile );
Nonetheless, those suppositions feel rather weak, and couldn't find info about it.
About the author
http://cyberiansoftware.com.ar/
#2
07/30/2009 (6:01 pm)
Thanks Michael.
#3
Actually, in your example above, Novack, both lines of code achieve exactly the same.
sfxPlayOnce is basically just a convenience function. The order of things in SFX dictates that you need to have an SFXDescription (how the sound is played) and SFXResource (internal; what the sound is) and an SFXProfile that brings both together. Then, an SFXSource is created from the SFXProfile that drives the actual playback.
This is invariant, i.e. it always happens.
However, as this is a huge overhead if you just want to play a single sound once, sfxPlayOnce takes care of all this allowing you to, for example, play directly from a file with just an SFXDescription. The temporary SFXProfile being created as well as the SFXSource are thrown away after playback has finished.
sfxPlay behaves exactly like sfxPlayOnce if you give it a profile and only is different if you call it with an SFXSource argument--in which case it is equivalent to SFXSource.play().
You see, sfxPlay actually provides little value. If not for backwards-compatibility, it should probably be removed.
08/01/2009 (8:23 pm)
Actually, in your example above, Novack, both lines of code achieve exactly the same.
sfxPlayOnce is basically just a convenience function. The order of things in SFX dictates that you need to have an SFXDescription (how the sound is played) and SFXResource (internal; what the sound is) and an SFXProfile that brings both together. Then, an SFXSource is created from the SFXProfile that drives the actual playback.
This is invariant, i.e. it always happens.
However, as this is a huge overhead if you just want to play a single sound once, sfxPlayOnce takes care of all this allowing you to, for example, play directly from a file with just an SFXDescription. The temporary SFXProfile being created as well as the SFXSource are thrown away after playback has finished.
sfxPlay behaves exactly like sfxPlayOnce if you give it a profile and only is different if you call it with an SFXSource argument--in which case it is equivalent to SFXSource.play().
You see, sfxPlay actually provides little value. If not for backwards-compatibility, it should probably be removed.
#4
Excellent Rene, much appreciated explanation.
08/01/2009 (8:37 pm)
Before removal, would be better a name swap I guess ;)Excellent Rene, much appreciated explanation.
#5
tdn.garagegames.com/wiki/TorqueGameEngineAdvanced/1_8_Beta/SFX/Overview
(sections 7 and 8)
08/01/2009 (8:44 pm)
Btw, I've been updating with all this scattered info, the SFX tdn page:tdn.garagegames.com/wiki/TorqueGameEngineAdvanced/1_8_Beta/SFX/Overview
(sections 7 and 8)
Associate Michael Hall
Distracted...
SFXPlay is of course used with a SFXProfile.