PlayingSfxInstance (class)

From Moondust Wiki
Revision as of 17:51, 31 May 2021 by Wohlstand (talk | contribs)
Jump to navigation Jump to search
OOjs UI icon notice-destructive.svg WARNING: PAGE INCOMPLETE, SOME OF THE FUNCTION ENTRIES MAY BE INACCURATE


This is class that manages the properties of a currently-playing sound effect. Objects of this class are generated for each audio clip played via the Audio.___Obj functions.

PlayingSfxInstance class
Type Function/Field Return values/Value type Description
function PlayingSfxInstance:Pause() nil Pauses the object's sound or loop
function PlayingSfxInstance:Resume() nil Resume the object's paused sound or loop
function PlayingSfxInstance:Stop() nil Stops the object's sound or loop. always returns 0
function PlayingSfxInstance:Expire(int ticks) nil Change the timed stoppage of the object's sound
function PlayingSfxInstance:FadeOut(int fade_ms) nil Fades out and stops the object's sound or loop with fade in length in milliseconds.
function PlayingSfxInstance:IsPlaying() boolean Returns true if the object's sound is currently playing.
function PlayingSfxInstance:IsPaused() boolean Returns true if the object's sound is currently paused.
function PlayingSfxInstance:IsFading() boolean Returns true if the object's sound is currently fading in or out.
function PlayingSfxInstance:Volume(int volume) nil Sets volume (from 0 to 128) of the object's sound.
function PlayingSfxInstance:SetPanning(int left, int right) nil Panning stereo effects. This effect will only work on stereo audio. Meaning you called Mix_OpenAudio with 2 channels. The easiest way to do true panning is to call SetPanning(left, 254 - left); so that the total volume is correct, if you consider the maximum volume to be 127 per channel for center, or 254 max for left, this works, but about halves the effective volume. NOTE: Setting both left and right to 255 will undo the effect from the object.
function PlayingSfxInstance:SetDistance(int distance) nil This effect simulates a simple attenuation of volume due to distance. The volume never quite reaches silence, even at max distance.

The volume never quite reaches silence, even at max distance.

NOTE: Using a distance of 0 will undo the effect.
function PlayingSfxInstance:Set3DPosition(int angle, int distance) nil This effect emulates a simple 3D audio effect. It's not all that realistic, but it can help improve some level of realism. By giving it the angle and distance from the camera's point of view, the effect pans and attenuates volumes. If you are looking for better positional audio, using OpenAL is suggested. NOTE: Using angle and distance of 0, will undo the effect
function PlayingSfxInstance:ReverseStereo(int flip) nil Simple reverse stereo, swaps left and right channel sound. NOTE: Using a flip of 0 will undo the effect.