Skip to content

Latest commit

 

History

History
93 lines (57 loc) · 3.4 KB

SFXParameter.rst

File metadata and controls

93 lines (57 loc) · 3.4 KB

SFXParameter

A sound channel value that can be bound to multiple sound sources.

Inherit:

SimObject

Description

Parameters are special objects that isolate a specific property that sound sources can have and allows to bind this isolated instance to multiple sound sources such that when the value of the parameter changes, all sources bound to the parameter will have their respective property changed.

Parameters are identified and referenced by their internalName. This means that the SFXDescription::parameters and SFXTrack::parameters fields should contain the internalNames of the SFXParameter objects which should be attached to the SFXSources when they are created. No two SFXParameters should have the same internalName.

All SFXParameter instances are automatically made children of the SFXParameterGroup.

Parameter Updates

Parameters are periodically allowed to update their own values. This makes it possible to attach custom logic to a parameter and have individual parameters synchronize their values autonomously. Use the onUpdate() callback to attach script code to a parameter update.

Example:

newSFXParameter( EngineRPMLevel )
{
   // Set the name by which this parameter is identified.
   internalName = "EngineRPMLevel";

   // Let this parameter control the pitch of attached sources to simulate engine RPM ramping up and down.
   channel = "Pitch";

   // Start out with unmodified pitch.
   defaultValue = 1;

   // Add a texture description of what this parameter does.
   description = "Engine RPM Level";
};

// Create a description that automatically attaches the engine RPM parameter.
singleton SFXDescription( EngineRPMSound : AudioLoop2D )
{
   parameters[ 0 ] = "EngineRPMLevel";
};

// Create sound sources for the engine.
sfxCreateSource( EngineRPMSound, "art/sound/engine/enginePrimary" );
sfxCreateSource( EngineRPMSound, "art/sound/engine/engineSecondary" );

// Setting the parameter value will now affect the pitch level of both sound sources.
EngineRPMLevel.value = 0.5;
EngineRPMLevel.value = 1.5;

Methods

Fields