Packagecom.yoambulante.midifiles
Classpublic class MidiFilesReader
InheritanceMidiFilesReader Inheritance flash.events.EventDispatcher

This class reads a standard MIDI file (.mid) and exposes all events through all different tracks found in the midi file



Public Properties
 PropertyDefined By
  loader : URLLoader
[read-only] This is the URLLoader instance used when loading external files.
MidiFilesReader
  resolution : uint
[read-only] resolution normally means how many ticks per quater note
MidiFilesReader
  subResolution : uint
[read-only] subResolution used when the midi file time is in frames per second
MidiFilesReader
  totalTracks : uint
[read-only] returns total amount of available tracks after loading.
MidiFilesReader
  tracksType : int
[read-only] MIDI file track type, 0: single track file format.
MidiFilesReader
Public Methods
 MethodDefined By
  
MidiFilesReader
  
getTrack(index:uint):MidiTrack
gets a track from list
MidiFilesReader
  
MIDI file track type, 0: single track file format.
MidiFilesReader
  
loadFile(filename:String):void
Loads externally a binary file with a MIDI standard estructure
MidiFilesReader
  
loadFromBytes(bin_file:ByteArray):void
Load a MIDI file structure from a ByteArray
MidiFilesReader
  
nextEvent():Boolean
You control the workflow and when the events are read.
MidiFilesReader
Events
 Event Summary Defined By
  Dispatched if during the reading process there was any unexpected byte or error.MidiFilesReader
  Dispatched when the midi file was read successfully and content valid data.MidiFilesReader
  Dispatched as soon as the midi header file was found when reading the binary content.MidiFilesReader
Public Constants
 ConstantDefined By
  ON_DATA_ERROR : String = ON_DATA_ERROR
[static]
MidiFilesReader
  ON_DATA_LOADED : String = ON_DATA_LOADED
[static]
MidiFilesReader
  ON_HEADER_LOADED : String = ON_HEADER_LOADED
[static]
MidiFilesReader
Property Detail
loaderproperty
loader:URLLoader  [read-only]

This is the URLLoader instance used when loading external files. Use this property to attach your own event listeners and have more control about the loading process workflow.


Implementation
    public function get loader():URLLoader
resolutionproperty 
resolution:uint  [read-only]

resolution normally means how many ticks per quater note


Implementation
    public function get resolution():uint
subResolutionproperty 
subResolution:uint  [read-only]

subResolution used when the midi file time is in frames per second


Implementation
    public function get subResolution():uint
totalTracksproperty 
totalTracks:uint  [read-only]

returns total amount of available tracks after loading.


Implementation
    public function get totalTracks():uint
tracksTypeproperty 
tracksType:int  [read-only]

MIDI file track type, 0: single track file format. 1:multiple track file format. 2:multiple song file format.


Implementation
    public function get tracksType():int
Constructor Detail
MidiFilesReader()Constructor
public function MidiFilesReader()



Method Detail
getTrack()method
public function getTrack(index:uint):MidiTrack

gets a track from list

Parameters

index:uint — must be a uint >= 0 and < totalTracks

Returns
MidiTrack — return null if index is equal or higher than totalTracks
getTrackTypeDescription()method 
public function getTrackTypeDescription():String

MIDI file track type, 0: single track file format. 1:multiple track file format. 2:multiple song file format.

Returns
String — String telling a detailed description
loadFile()method 
public function loadFile(filename:String):void

Loads externally a binary file with a MIDI standard estructure

Parameters

filename:String — url of the .mid file, it can be both a local file or a remote location from a web server (see security limitations)

loadFromBytes()method 
public function loadFromBytes(bin_file:ByteArray):void

Load a MIDI file structure from a ByteArray

Parameters

bin_file:ByteArrayByteArray file, note that you must specify the starting position of the file, this function doesn't set bin_file.position = 0

nextEvent()method 
public function nextEvent():Boolean

You control the workflow and when the events are read. As long as you're ready for carry on reading the file just call nextEvent

Returns
Boolean — returns true if any data was read, otherwise false, normally when it reaches the end of the file.
Event Detail
ON_DATA_ERROR Event
Event Object Type: flash.events.Event
Event.type property = com.yoambulante.midifiles.MidiFilesReader.ON_DATA_ERROR

Dispatched if during the reading process there was any unexpected byte or error.

ON_DATA_LOADED Event  
Event Object Type: flash.events.Event
Event.type property = com.yoambulante.midifiles.MidiFilesReader.ON_DATA_LOADED

Dispatched when the midi file was read successfully and content valid data.

ON_HEADER_LOADED Event  
Event Object Type: flash.events.Event
Event.type property = com.yoambulante.midifiles.MidiFilesReader.ON_HEADER_LOADED

Dispatched as soon as the midi header file was found when reading the binary content.

Constant Detail
ON_DATA_ERRORConstant
public static const ON_DATA_ERROR:String = ON_DATA_ERROR

ON_DATA_LOADEDConstant 
public static const ON_DATA_LOADED:String = ON_DATA_LOADED

ON_HEADER_LOADEDConstant 
public static const ON_HEADER_LOADED:String = ON_HEADER_LOADED