PlayingSfxInstance (class)

From Moondust Wiki
Revision as of 12:02, 3 January 2017 by Rockythechao (talk | contribs)
Jump to navigation Jump to search

-- 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 Channel, int left, int right) int 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 SfxSetPanning(channel, 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.

This Function registers the effect for you, so don't try to Mix_RegisterEffect it yourself. NOTE: Setting both left and right to 255 will unregister the effect from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel. NOTE: Using this function on a mono audio device will not register the effect, nor will it return an error status.

Returns: Zero on errors, such as bad channel, or if Mix_RegisterEffect failed.
function PlayingSfxInstance:SetDistance(int Channel, int distance) int This effect simulates a simple attenuation of volume due to distance. The volume never quite reaches silence, even at max distance.

NOTE: Using a distance of 0 will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.

Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.
function PlayingSfxInstance:Set3DPosition(int Channel, int angle, int distance) int 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 cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.

Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.
function PlayingSfxInstance:ReverseStereo(int Channel, int flip) int Simple reverse stereo, swaps left and right channel sound.

NOTE: Using a flip of 0, will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.

Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.