Packagecom.yoambulante.midifiles
Classpublic class SamplesExtractor
InheritanceSamplesExtractor Inheritance flash.events.EventDispatcher

This class extracts audio samples from a (flash.media.Sound) object and turn them to a Vector.<Point> where .x represents the right channel value and .y the left channel value.



Public Properties
 PropertyDefined By
  MAX_EXTRACTION_PER_GO : uint = 10000
[static] Everytime .extract() is called it will try to extract up to this amount of samples
SamplesExtractor
  totalSamples : uint
[read-only] total amount of samples available after extraction
SamplesExtractor
Public Methods
 MethodDefined By
  
SamplesExtractor(snd:Sound)
Creates a SamplesExtractor instance
SamplesExtractor
  
extract():void
start extracting all samples from a Sound defined on constructor
SamplesExtractor
  
readSampleAt(index:uint):Point
get a stereo sample in form of a Point from the extracted sample list
SamplesExtractor
Events
 Event Summary Defined By
  Dispatched when the extraction process has finished.SamplesExtractor
  Dispatched during the extraction process, helps to know the percentage progress of the current extraction process.SamplesExtractor
Property Detail
MAX_EXTRACTION_PER_GOproperty
public static var MAX_EXTRACTION_PER_GO:uint = 10000

Everytime .extract() is called it will try to extract up to this amount of samples

totalSamplesproperty 
totalSamples:uint  [read-only]

total amount of samples available after extraction


Implementation
    public function get totalSamples():uint
Constructor Detail
SamplesExtractor()Constructor
public function SamplesExtractor(snd:Sound)

Creates a SamplesExtractor instance

Parameters
snd:SoundSound object where to extract samples from. IMPORTANT, this sound must represent a waveform in A440 frequency
Method Detail
extract()method
public function extract():void

start extracting all samples from a Sound defined on constructor

See also


Example
The following code extracts samples from a Sound
         var snd:Sound = new MySound(); //MySound is a sound in the library extending flash.media.Sound Class
         var ext:SamplesExtractor = new SamplesExtractor(snd);
         ext.addEventListener(ProgressEvent.PROGRESS, extractingSamples); //progress
         ext.addEventListener(Event.COMPLETE, samplesReady);    //when is finishes
         ext.extract();
         
readSampleAt()method 
public function readSampleAt(index:uint):Point

get a stereo sample in form of a Point from the extracted sample list

Parameters

index:uint

Returns
Point — a stereo sample in form of a Point where .x represent right channel and .y left channel
Event Detail
COMPLETE Event
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE

Dispatched when the extraction process has finished. Call .extract method for start extracting all samples.

PROGRESS Event  
Event Object Type: flash.events.ProgressEvent
ProgressEvent.type property = flash.events.ProgressEvent.PROGRESS

Dispatched during the extraction process, helps to know the percentage progress of the current extraction process.