Packageorg.as3wavsound
Classpublic class WavSoundChannel
InheritanceWavSoundChannel Inheritance flash.events.EventDispatcher

Used to keep track of open channels during playback. Each channel represents an 'instance' of a sound and so each channel is responsible for its own mixing. The WavSound class uses the WavSoundPlayer to play instances of itself and returns the WavSoundChannel returned by the player. Also, the WavSoundPlayer uses the buffer() function to make the playing WavSoundChannel mix its own samples into the master buffer. Dispatches the Event.SOUND_COMPLETE event when the last sample has been mixed into the master buffer. Also see buffer().



Public Properties
 PropertyDefined By
  leftPeak : Number
[read-only]
WavSoundChannel
  position : Number
[read-only] Returns the current position in milliseconds: phase wavSound.length / wavSound.samples.length
WavSoundChannel
  rightPeak : Number
[read-only]
WavSoundChannel
  soundTransform : SoundTransform
[read-only]
WavSoundChannel
Public Methods
 MethodDefined By
  
WavSoundChannel(player:WavSoundPlayer, wavSound:WavSound, startTime:Number, loops:int, soundTransform:SoundTransform)
Constructor: pre-calculates starting phase (and performs some validation for this), see init().
WavSoundChannel
  
buffer(sampleBuffer:AudioSamples):void
Called from WavSoundPlayer when the player is ready to mix new samples into the master sample buffer.
WavSoundChannel
  
init(startTime:Number, loops:int):void
Calculates and validates the starting time.
WavSoundChannel
  
stop():void
Tells the WavsoundPlayer to stop this specific SoundWavChannel instance.
WavSoundChannel
Property Detail
leftPeakproperty
leftPeak:Number  [read-only]


Implementation
    public function get leftPeak():Number
positionproperty 
position:Number  [read-only]

Returns the current position in milliseconds: phase wavSound.length / wavSound.samples.length


Implementation
    public function get position():Number
rightPeakproperty 
rightPeak:Number  [read-only]


Implementation
    public function get rightPeak():Number
soundTransformproperty 
soundTransform:SoundTransform  [read-only]


Implementation
    public function get soundTransform():SoundTransform
Constructor Detail
WavSoundChannel()Constructor
public function WavSoundChannel(player:WavSoundPlayer, wavSound:WavSound, startTime:Number, loops:int, soundTransform:SoundTransform)

Constructor: pre-calculates starting phase (and performs some validation for this), see init().

Parameters
player:WavSoundPlayer
 
wavSound:WavSound
 
startTime:Number
 
loops:int
 
soundTransform:SoundTransform
Method Detail
buffer()method
public function buffer(sampleBuffer:AudioSamples):void

Called from WavSoundPlayer when the player is ready to mix new samples into the master sample buffer. Fills a target samplebuffer with (optionally transformed) samples from the current WavSoundChannel instance. Keeps filling the buffer until the last samples are buffered or until the buffersize is reached. When the buffer is full, phase and loopsLeft keep track of how which samples still need to be buffered in the next buffering cycle (when this method is called again).

Parameters

sampleBuffer:AudioSamples — The target buffer to mix in the current (transformed) samples.

init()method 
public function init(startTime:Number, loops:int):void

Calculates and validates the starting time. Starting time in milliseconds is converted into sample position and then marked as starting phase. Also resets finished state and sets 'loopsLeft' equal to the given 'loops' value.

Parameters

startTime:Number
 
loops:int

stop()method 
public function stop():void

Tells the WavsoundPlayer to stop this specific SoundWavChannel instance.