Packagecom.noteflight.standingwave2.elements
Classpublic class Sample
InheritanceSample Inheritance Object
Implements IAudioSource, IRandomAccessSource

Sample is the fundamental audio source in StandingWave, and is simply a set of buffers containing the individual numeric samples of an audio signal. The channelData property is an Array of channel buffers, whose length is the number of channels specified by the descriptor. Each channel buffer is a Vector of Numbers, whose elements are the individual samples for that channel, ranging between -1 and +1.



Public Properties
 PropertyDefined By
  channelData : Array
Array of Vectors of data samples as Numbers, one Vector per channel.
Sample
  channels : Number
[read-only] The number of channels in this sample
Sample
  descriptor : AudioDescriptor
[read-only] The AudioDescriptor describing the audio characteristics of this source.
Sample
  duration : Number
[read-only] Return duration in seconds
Sample
  frameCount : Number
The number of sample frames in this source.
Sample
  position : Number
The position of the audio cursor in this source, as a frame index.
Sample
Public Methods
 MethodDefined By
  
Sample(descriptor:AudioDescriptor, frames:Number = -1)
Construct a new, empty Sample with some specified audio format.
Sample
  
clear():void
Clear this sample.
Sample
  
Clone this Sample.
Sample
  
getChannelSample(channel:Number, index:Number):Number
Return a sample for the given channel and frame index
Sample
  
getInterpolatedSample(channel:Number, pos:Number):Number
Return an interpolated sample for a non-integral sample position.
Sample
  
getSample(numFrames:Number):Sample
Retrieve a number of sample frames from this source as a Sample object, starting from the audio cursor position.
Sample
  
getSampleRange(fromOffset:Number, toOffset:Number):Sample
Return a Sample representing a concrete subrange of this source.
Sample
  
Resets the audio cursor to the beginning of the source, and causes any cursor-dependent state in the source to be initialized.
Sample
Property Detail
channelDataproperty
public var channelData:Array

Array of Vectors of data samples as Numbers, one Vector per channel.

channelsproperty 
channels:Number  [read-only]

The number of channels in this sample


Implementation
    public function get channels():Number
descriptorproperty 
descriptor:AudioDescriptor  [read-only]

The AudioDescriptor describing the audio characteristics of this source.


Implementation
    public function get descriptor():AudioDescriptor
durationproperty 
duration:Number  [read-only]

Return duration in seconds


Implementation
    public function get duration():Number
frameCountproperty 
frameCount:Number

The number of sample frames in this source. An unbounded source may return Number.MAX_VALUE.


Implementation
    public function get frameCount():Number
    public function set frameCount(value:Number):void
positionproperty 
position:Number

The position of the audio cursor in this source, as a frame index.


Implementation
    public function get position():Number
    public function set position(value:Number):void
Constructor Detail
Sample()Constructor
public function Sample(descriptor:AudioDescriptor, frames:Number = -1)

Construct a new, empty Sample with some specified audio format.

Parameters
descriptor:AudioDescriptor — an AudioDescriptor specifying the audio format of this sample.
 
frames:Number (default = -1) — the number of frames in this Sample. If omitted or negative, no channel data vectors are created. If zero, then zero-length vectors are created and may be grown in size. If positive, then fixed-size vectors are created, and will contain zeroes.
Method Detail
clear()method
public function clear():void

Clear this sample.

clone()method 
public function clone():IAudioSource

Clone this Sample. Note that the channel data is shared between the original and the clone, since channel data inside a Sample should never be mutated except for temporary Samples used inside a filter pipeline.

Returns
IAudioSource
getChannelSample()method 
public function getChannelSample(channel:Number, index:Number):Number

Return a sample for the given channel and frame index

Parameters

channel:Number — the channel index of the sample
 
index:Number — the frame index of the sample within that channel

Returns
Number
getInterpolatedSample()method 
public function getInterpolatedSample(channel:Number, pos:Number):Number

Return an interpolated sample for a non-integral sample position. Interpolation is always done within the same channel.

Parameters

channel:Number
 
pos:Number

Returns
Number
getSample()method 
public function getSample(numFrames:Number):Sample

Retrieve a number of sample frames from this source as a Sample object, starting from the audio cursor position. It is not legal to request frames beyond the maximum index indicated by the frameCount property.

Parameters

numFrames:Number — an integral number of frames.

Returns
Sample — a Sample object containing the requested sample frames.
getSampleRange()method 
public function getSampleRange(fromOffset:Number, toOffset:Number):Sample

Return a Sample representing a concrete subrange of this source.

Parameters

fromOffset:Number — the starting point of the range (inclusive)
 
toOffset:Number — the endpoint of the range (exclusive)

Returns
Sample
resetPosition()method 
public function resetPosition():void

Resets the audio cursor to the beginning of the source, and causes any cursor-dependent state in the source to be initialized.