Package | com.anttikupila.media |
Class | public class SoundFX |
Inheritance | SoundFX ![]() |
Provides an easy way to transform audio output in real time with a syntax familiar from display object filters
var sound : SoundFX = new SoundFX( new URLRequest( "music.mp3" ) ); sound.filters = [ new CutoffFilter( 12000 ) ]; sound.play( );
SoundFX also provides greated control over buffering and precise seeking
var sound : SoundFX = new SoundFX( null, null, 3 ); // 3 seconds need to be loaded before playback starts sound.load( new URLRequest( "music.mp3" ) ); sound.play( ); // a bit later.. sound.position = 3.12312;
Property | Defined By | ||
---|---|---|---|
filters : Array
Indexed array of filters to process the audio through before output
| SoundFX | ||
isBuffering : Boolean [read-only]
| SoundFX | ||
networkBuffer : Number
Amount of seconds that need to be buffered before sound will start playing
| SoundFX | ||
outputBuffer : Number
Output buffer size
| SoundFX | ||
paused : Boolean
Specifies if the track is paused. | SoundFX | ||
position : Number
Current playhead position
| SoundFX |
Method | Defined By | ||
---|---|---|---|
SoundFX(stream:URLRequest = null, context:SoundLoaderContext = null, networkBufferSeconds:Number, outputBufferLength:int) | SoundFX | ||
getLength():Number
Return an estimated length based on currently loaded bytes
While the result isn't exactly correct it is useful for showing progress of the playing track, dividing SoundFX.position with SoundFX.getLenght()
| SoundFX | ||
load(stream:URLRequest, context:SoundLoaderContext = null):void | SoundFX | ||
play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel
Starts playing the sound
Note: unlike flash.media.Sound play() does not return a SoundChannel
| SoundFX |
Method | Defined By | ||
---|---|---|---|
bufferTimerHandler(event:TimerEvent):void | SoundFX | ||
soundCompleteHandler(event:Event):void | SoundFX |
Constant | Defined By | ||
---|---|---|---|
DEFAULT_NETWORK_BUFFER : Number = 1 [static] | SoundFX | ||
DEFAULT_OUTPUT_BUFFER : int = 2048 [static] | SoundFX | ||
SAMPLE_RATE : int = 44100 [static] | SoundFX |
filters | property |
filters:Array
[read-write] Indexed array of filters to process the audio through before output
public function get filters():Array
public function set filters(value:Array):void
isBuffering | property |
isBuffering:Boolean
[read-only]
public function get isBuffering():Boolean
networkBuffer | property |
networkBuffer:Number
[read-write] Amount of seconds that need to be buffered before sound will start playing
public function get networkBuffer():Number
public function set networkBuffer(value:Number):void
outputBuffer | property |
outputBuffer:Number
[read-write] Output buffer size
public function get outputBuffer():Number
public function set outputBuffer(value:Number):void
paused | property |
paused:Boolean
[read-write] Specifies if the track is paused. Unlike stopping a track pausing it will continue to process filters without advancing the playhead.
public function get paused():Boolean
public function set paused(value:Boolean):void
position | property |
position:Number
[read-write] Current playhead position
public function get position():Number
public function set position(value:Number):void
SoundFX | () | Constructor |
public function SoundFX(stream:URLRequest = null, context:SoundLoaderContext = null, networkBufferSeconds:Number, outputBufferLength:int)
Parameters
stream:URLRequest (default = null ) — File to load
| |
context:SoundLoaderContext (default = null ) — Context
| |
networkBufferSeconds:Number (default = NaN ) — Network buffer in seconds. Similar to the buffer in NetStream
| |
outputBufferLength:int (default = NaN ) — Output buffer in samples. If the output is choppy even if the network is smooth try increasing the output buffer
|
bufferTimerHandler | () | method |
protected function bufferTimerHandler(event:TimerEvent):void
Parameters
event:TimerEvent |
getLength | () | method |
public function getLength():Number
Return an estimated length based on currently loaded bytes
While the result isn't exactly correct it is useful for showing progress of the playing track, dividing SoundFX.position with SoundFX.getLenght()
ReturnsNumber — An estimated length
|
See also
load | () | method |
override public function load(stream:URLRequest, context:SoundLoaderContext = null):void
Parameters
stream:URLRequest | |
context:SoundLoaderContext (default = null )
|
See also
play | () | method |
override public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel
Starts playing the sound
Note: unlike flash.media.Sound
play() does not return a SoundChannel
Parameters
startTime:Number (default = 0 ) — Start time in seconds
| |
loops:int (default = 0 ) — Number of loops
| |
sndTransform:SoundTransform (default = null ) — Sound transform
|
SoundChannel — null
|
soundCompleteHandler | () | method |
protected function soundCompleteHandler(event:Event):void
Parameters
event:Event |
DEFAULT_NETWORK_BUFFER | Constant |
public static const DEFAULT_NETWORK_BUFFER:Number = 1
DEFAULT_OUTPUT_BUFFER | Constant |
public static const DEFAULT_OUTPUT_BUFFER:int = 2048
SAMPLE_RATE | Constant |
public static const SAMPLE_RATE:int = 44100