sound.<...>

Return to Introduction  Previous page  Next page

Controls the playback of a sound.

 

Syntax

 

play()

Plays the current sound once.

stop()

Stops the sound from playing.

setVolume(level)

Sets the volume of the sound, where level is between 0 (silent) and 1 (full).

setPan(pos)

Sets the left/right pan of the sound, where pos is between -1 (left) and 1 (right).  Not applicable to positioned sounds.

frequency

Integer value that determines the frequency (Hz) the sound is played at (useful to modify this for engine notes).  If coming from a floating point value, use Math.floor(fVal) to get a usable integer for this function.

setPolyphony(nVoice)

Sets the sound to allow playback through a number of voices at once (defaults to 1).  2 would allow two copies of the sound to play at once, etc.

duration

Returns a float for the duration of the sound in seconds.

 

Examples

 

sounds.ping.play(); // plays the sound called 'ping'.

 

Remarks

 

If the sound has been set as 'positioned' when played from an object, the sound will be played in 3D space according to the position of the object relative to the current camera.

 

See Also

 

Script Reference



Copyright ©2004 Worldweaver Ltd. DX Studio Home