TorqueGameEngineAdvanced/1 8 Beta/SFX/Overview
From TDN
[edit] IntroductionSFX is the new 2D and 3D audio system for Torque. It was designed to provide the basic features for sound playback across multiple platforms, sound devices, and audio libraries. [edit] ProvidersThe SFXProvider is the abstraction for the low level sound system which will vary on different platforms. There is only one active provider at any time and it is used to create an instance of the SFXDevice. [edit] DirectSoundThe DirectSound API is the original DirectX audio playback and recording library for Microsoft Windows. While it supports hardware acceleration of sound mixing it was plagued by bad driver support. Microsoft is no longer extending DirectSound and it should be avoided in future projects. [edit] XAudioThe XAudio provider is exclusive to Microsoft Windows and XBox and is the replacement for DirectSound. It is a pure software mixer which makes it more reliable and consistent in performance. It is recommended as the standard SFX provider on Microsoft platforms. [edit] OpenALThe Open Audio Library sound provider for SFX is cross platform and supported on Windows, OSX, and various open source operating systems. [edit] FMODThe FMOD audio library is a commercial product which itself abstracts various audio APIs and platforms. In this respect it is a redundancy with functionality already in SFX, but it also supports some higher level features and improvements which you could potentially tap into for your specific game. [edit] NullThe null provider acts like a normal sound provider, but it does not playback any audio. Its only provided for testing and debugging. [edit] DevicesEach provider in SFX will have one or more output devices. The devices usually match audio outputs on the platform like multiple sound cards, specific physical audio jacks, and sometimes different APIs. In general the first returned device from the provider is the appropriate default device for that platform. [edit] SourcesA source in SFX is a controller for playback of audio. You can create a source instance via C++ and/or TorqueScript and use it to manage playback and sound properties such as spacial positioning, velocity, cone settings, volume, and pitch. [edit] Profiles and DescriptionsIn SFX the sound profile and descrption work together to define a sound for playback including the path to the file on disk and the default properties for how sounds are to be played at the time of creation. [edit] StreamingThe current version of SFX does not abstract support for threaded sound streaming from disk. This means that all playing sounds must be loaded in their entirety in memory before playback can begin. This will affect you most with long sound files like music, but it also limits the ability to play streaming audio from the GuiTheoraCtrl. [edit] Basic ReferenceThis was taken from different froum threads, where Tom Spilman and Rene Damm, introduced some basics on the use of the SFX system.
%source = SFXPlay( MyProfile ); %source.setVolume( 0.5 ); %source.setPitch( 0.5 ); %source.setTransform( "10 10 20" ); It also has other functions like play(), stop(), pause(), isPlaying(), isPaused(), etc. You can see more details in the C++ reference docs for SFXSource and also in the Torsion code browser window.
%this.someSource = SFXPlayOnce( MyProfile ); // Then sometime later... if ( isObject( %this.someSource ) ) %this.someSource.pause();
new SimSet( PausedSimSounds ); sfxPause( $SimAudioType, PausedSimSounds ); sfxPause( $MessageAudioType, PausedSimSounds ); // Then when you want to resume them... sfxResume( PausedSimSounds );
sfxPlayOnce( MySoundProfile );
function SFXSource::onStatus( %this, %status )
{
if ( %status $= "stopped" )
echo( "The source stopped!" );
}
%source = SFXPlayOnce( MyProfile ); // or %source = SFXPlay( MyProfile ); In the example above, both lines of code achieve exactly the same. %obj.playAudio(0,sfxName);
[edit] Best PracticesThis was taken from a froum thread, where Robert Blanchet Jr. made some recomendations on the proper use of the SFX system.
|



