C# Class flxSharp.flxSharp.FlxSound

This is the universal flixel sound object, used for streaming, music, and sound effects. For all the pan stuff http://allcomputers.us/windows_phone/xna-game-studio-4_0---playing-sound-effects-(part-1)---using-soundeffect-for-audio-playback.aspx TODO: Implement overloaded functionality for Sound (mp3 files) all over the place...
Inheritance: FlxBasic
Datei anzeigen Open project: jlorek/flxSharp

Public Properties

Property Type Description
amplitude float
amplitudeLeft float
amplitudeRight float
artist string
autoDestroy bool
name string
survive bool
x float
y float

Protected Properties

Property Type Description
_fadeInTimer float
_fadeInTotal float
_fadeOutTimer float
_fadeOutTotal float
_looped bool
_pan bool
_pauseOnFadeOut bool
_position float
_radius float
_sound Microsoft.Xna.Framework.Audio.SoundEffectInstance
_target FlxObject
_volume float
_volumeAdjust float

Public Methods

Method Description
FlxSound ( ) : System

The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.

destroy ( ) : void

Clean up memory.

fadeIn ( float seconds ) : void

Call this function to make a sound fade in over a certain time interval (calls play() automatically).

fadeOut ( float seconds, bool pauseInstead = false ) : void

Call this function to make this sound fade out over a certain time interval.

getActualVolume ( ) : float

Returns the currently selected "real" volume of the sound (takes fades and proximity into account).

kill ( ) : void
loadEmbedded ( SoundEffect embeddedSound, bool looped = false, bool autoDestroy = false ) : FlxSound

One of two main setup functions for sounds, this function loads a sound from an embedded MP3.

loadStream ( string soundUrl, bool looped = false, bool autoDestroy = false ) : FlxSound

One of two main setup functions for sounds, this function loads a sound from a URL.

pause ( ) : void

Call this function to pause this sound.

play ( bool forceRestart = false ) : void

Call this function to play the sound - also works on paused sounds.

proximity ( float x, float y, FlxObject target, float radius, bool pan = true ) : FlxSound

Call this function if you want this sound's volume to change based on distance from a particular FlxCore object.

resume ( ) : void

Unpause a sound. Only works on sounds that have been paused.

stop ( ) : void

Call this function to stop this sound.

update ( ) : void

Handles fade out, fade in, panning, proximity, and amplitude operations each frame.

Protected Methods

Method Description
createSound ( ) : void

An internal function for clearing all the variables used by sounds.

Private Methods

Method Description
updateTransform ( ) : void

Call after adjusting the volume to update the sound channel's settings.

Method Details

FlxSound() public method

The FlxSound constructor gets all the variables initialized, but NOT ready to play a sound yet.
public FlxSound ( ) : System
return System

createSound() protected method

An internal function for clearing all the variables used by sounds.
protected createSound ( ) : void
return void

destroy() public method

Clean up memory.
public destroy ( ) : void
return void

fadeIn() public method

Call this function to make a sound fade in over a certain time interval (calls play() automatically).
public fadeIn ( float seconds ) : void
seconds float The amount of time the fade-in operation should take.
return void

fadeOut() public method

Call this function to make this sound fade out over a certain time interval.
public fadeOut ( float seconds, bool pauseInstead = false ) : void
seconds float The amount of time the fade out operation should take.
pauseInstead bool Tells the sound to pause on fadeout, instead of stopping.
return void

getActualVolume() public method

Returns the currently selected "real" volume of the sound (takes fades and proximity into account).
public getActualVolume ( ) : float
return float

kill() public method

public kill ( ) : void
return void

loadEmbedded() public method

One of two main setup functions for sounds, this function loads a sound from an embedded MP3.
public loadEmbedded ( SoundEffect embeddedSound, bool looped = false, bool autoDestroy = false ) : FlxSound
embeddedSound Microsoft.Xna.Framework.Audio.SoundEffect An embedded Class object representing an MP3 file.
looped bool Whether or not this sound should loop endlessly.
autoDestroy bool Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.
return FlxSound

loadStream() public method

One of two main setup functions for sounds, this function loads a sound from a URL.
public loadStream ( string soundUrl, bool looped = false, bool autoDestroy = false ) : FlxSound
soundUrl string A string representing the URL of the MP3 file you want to play.
looped bool Whether or not this sound should loop endlessly.
autoDestroy bool Whether or not this FlxSound instance should be destroyed when the sound finishes playing. Default value is false, but FlxG.play() and FlxG.stream() will set it to true by default.
return FlxSound

pause() public method

Call this function to pause this sound.
public pause ( ) : void
return void

play() public method

Call this function to play the sound - also works on paused sounds.
public play ( bool forceRestart = false ) : void
forceRestart bool Whether to start the sound over or not. Default value is false, meaning if the sound is already playing or was paused when you call play(), it will continue playing from its current position, NOT start again from the beginning.
return void

proximity() public method

Call this function if you want this sound's volume to change based on distance from a particular FlxCore object.
public proximity ( float x, float y, FlxObject target, float radius, bool pan = true ) : FlxSound
x float The X position of the sound.
y float The Y position of the sound.
target FlxObject The object you want to track.
radius float The maximum distance this sound can travel.
pan bool Whether the sound should pan in addition to the volume changes (default: true).
return FlxSound

resume() public method

Unpause a sound. Only works on sounds that have been paused.
public resume ( ) : void
return void

stop() public method

Call this function to stop this sound.
public stop ( ) : void
return void

update() public method

Handles fade out, fade in, panning, proximity, and amplitude operations each frame.
public update ( ) : void
return void

Property Details

_fadeInTimer protected_oe property

Internal timer for fading in the sound playback.
protected float _fadeInTimer
return float

_fadeInTotal protected_oe property

Internal helper for fading in sounds.
protected float _fadeInTotal
return float

_fadeOutTimer protected_oe property

Internal timer used to keep track of requests to fade out the sound playback.
protected float _fadeOutTimer
return float

_fadeOutTotal protected_oe property

Internal helper for fading out sounds.
protected float _fadeOutTotal
return float

_looped protected_oe property

Internal tracker for whether the sound is looping or not.
protected bool _looped
return bool

_pan protected_oe property

Internal tracker for whether to pan the sound left and right. Default is false.
protected bool _pan
return bool

_pauseOnFadeOut protected_oe property

Internal flag for whether to pause or stop the sound when it's done fading out.
protected bool _pauseOnFadeOut
return bool

_position protected_oe property

Internal tracker for the position in runtime of the music playback.
protected float _position
return float

_radius protected_oe property

Internal tracker for the maximum effective radius of this sound (for proximity and panning).
protected float _radius
return float

_sound protected_oe property

Internal tracker for a XNA sound object.
protected SoundEffectInstance,Microsoft.Xna.Framework.Audio _sound
return Microsoft.Xna.Framework.Audio.SoundEffectInstance

_target protected_oe property

Internal tracker for the sound's "target" (for proximity and panning).
protected FlxObject,flxSharp.flxSharp _target
return FlxObject

_volume protected_oe property

Internal tracker for how loud the sound is.
protected float _volume
return float

_volumeAdjust protected_oe property

Internal tracker for total volume adjustment.
protected float _volumeAdjust
return float

amplitude public_oe property

Stores the average wave amplitude of both stereo channels.
public float amplitude
return float

amplitudeLeft public_oe property

Just the amplitude of the left stereo channel.
public float amplitudeLeft
return float

amplitudeRight public_oe property

Just the amplitude of the right stereo channel.
public float amplitudeRight
return float

artist public_oe property

The ID3 artist name. Defaults to null. Currently only works for streamed sounds.
public string artist
return string

autoDestroy public_oe property

Whether to call destroy() when the sound has finished.
public bool autoDestroy
return bool

name public_oe property

The ID3 song name. Defaults to null. Currently only works for streamed sounds.
public string name
return string

survive public_oe property

Whether or not this sound should be automatically destroyed when you switch states.
public bool survive
return bool

x public_oe property

The X position of this sound in world coordinates. Only really matters if you are doing proximity/panning stuff.
public float x
return float

y public_oe property

The Y position of this sound in world coordinates. Only really matters if you are doing proximity/panning stuff.
public float y
return float