In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: MIDIシーケンスを演奏してみた

デフォルトのMIDIは,kashiwa@正直日記さんのものをお借りしました.
最初に,ドラムをプリレンダリングするため,少し待ってください.
ほんのちょっと複雑なMIDIファイルを鳴らすだけで,
誰でも簡単にブラウザクラッシュができます.
/**
 * Copyright civet ( http://wonderfl.net/user/civet )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rdrN
 */

// forked from keim_at_Si's MIDIシーケンスを演奏してみた
// forked from nemu90kWw's MIDIシーケンスを解析してみた
//
// デフォルトのMIDIは,kashiwa@正直日記さんのものをお借りしました.
// 最初に,ドラムをプリレンダリングするため,少し待ってください.
// ほんのちょっと複雑なMIDIファイルを鳴らすだけで,
// 誰でも簡単にブラウザクラッシュができます.
package
{
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.net.*;
	import flash.utils.ByteArray;
	import mx.utils.Base64Decoder;
	
	[SWF(width="465", height="465", frameRate="24")]
	public class main extends Sprite
	{
		private var button:Sprite;
		private var playButton:Sprite, stopButton:Sprite;
		private var fileReference:FileReference;
		
		private var textfield:TextField = new TextField();
		private var information:TextField = new TextField();
		
		private var midi:SMFSequence;
	    
		private var midiPlayer:MIDIPlayer;
		
		function main()
		{
			textfield.width = 465
			textfield.height = 465-30;
			textfield.y = 30;
			textfield.wordWrap = true;
			addChild(textfield);
			
			information.width = 232;
			information.height = 30;
			information.x = 235;
			information.y = 10;
			addChild(information);
		    
			var decoder:Base64Decoder = new Base64Decoder();
			decoder.decode(SMFBinary.data);
			
			var ba:ByteArray = decoder.toByteArray();
			ba.uncompress();
			
			midi = new SMFSequence(ba);
			textfield.text = midi.toString();
			
			button     = b(5, 5, "Open SMF");
			playButton = b(130, 5, "Play");
			stopButton = b(130, 5, "Stop");
			stopButton.visible = false;
			function b(x:Number, y:Number, label:String) : Sprite {
		            var button:Sprite = new Sprite(),
    		            buttontext:TextField = new TextField();
		        
			    button.x = x;
			    button.y = y;
			    button.mouseChildren = false;
			    button.buttonMode = true;
			    button.graphics.lineStyle(1, 0xBBBBBB);
			    button.graphics.beginFill(0xEEEEEE);
			    button.graphics.drawRoundRect(0, 0, 100, 20, 5, 5);
			    button.graphics.endFill();
			    addChild(button);
			
			    buttontext.width = 100;
			    buttontext.height = 20;
			    buttontext.htmlText = "<p align='center'><font face='_sans'>" + label + "</span></p>";
			    button.addChild(buttontext);
			
		            return button;
		        }
		    
			fileReference = new FileReference();
			fileReference.addEventListener(Event.SELECT, onSelect);
			fileReference.addEventListener(Event.COMPLETE, onComplete);
			button.addEventListener(MouseEvent.CLICK, onClick);
			playButton.addEventListener(MouseEvent.CLICK, onPlay);
			stopButton.addEventListener(MouseEvent.CLICK, onStop);
			addEventListener(Event.ENTER_FRAME, onEnverFrame);
		    
			midiPlayer = new MIDIPlayer();

			//demo button
			var demoButton:Sprite = b(350, 5, "Load Demo");
			demoButton.addEventListener(MouseEvent.CLICK, onLoadDemo);
                        
		}

		//load a demo midi
		private function onLoadDemo(event:MouseEvent):void
		{
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onDemoLoaded);
			loader.dataFormat = URLLoaderDataFormat.BINARY;
			loader.load(new URLRequest("http://www.dreamana.com/lab/sion/midi/" + int(Math.random() * 6 ) + ".mid"));
		}
		private function onDemoLoaded(event:Event):void
		{
			midi = new SMFSequence(event.currentTarget.data);
			textfield.text = midi.toString();
		}
		
		private function onClick(event:MouseEvent):void 
		{
			fileReference.browse([new FileFilter("MIDIシーケンス(mid)", "*.mid")]);
		}
	    
		private function onSelect(event:Event):void
		{
			fileReference.load();
		}
		
		private function onComplete(event:Event):void
		{
			midi = new SMFSequence(fileReference.data);
			textfield.text = midi.toString();
		}
	    
	    private function onPlay(event:MouseEvent):void 
	    {
	        midiPlayer.play(midi);
	        playButton.visible = false;
	        stopButton.visible = true;
	    }
	    
	    private function onStop(event:MouseEvent):void 
	    {
	        driver.stop();
	        playButton.visible = true;
	        stopButton.visible = false;
	    }
	    
	    private function onEnverFrame(event:Event):void
	    {
	        information.text = "position : " + (driver.position*0.001).toFixed(1) + "[sec]";
	    }
	}
}




import flash.text.*;
import org.si.sion.*;
import org.si.sion.sequencer.SiMMLTrack;
import org.si.sion.utils.SiONPresetVoice;
import org.si.sion.namespaces._sion_internal;

var driver:SiONDriver;

var trackCountLimit:int = 24;
var freePointer:int = 0;
function freeNoteOffTracks() : void {
    var tr:SiMMLTrack, activeTracks:int, i:int, imax:int = driver.trackCount;
    for (activeTracks=0, i=0; i<imax; i++) {
        tr = driver.sequencer.tracks[i];
        if (tr.isActive) activeTracks++;
    }
    if (activeTracks > trackCountLimit) {
        for (activeTracks=0, i=0; i<imax; i++) {
            if (++freePointer == imax) freePointer = 0;
            tr = driver.sequencer.tracks[freePointer];
            if (!tr.channel.isIdling && !tr.channel.isNoteOn()) {
                tr.channel.reset();
                if (--activeTracks == trackCountLimit) return;
            }
        }
        for (i=activeTracks - trackCountLimit; i>=0; --i) {
            if (++freePointer == imax) freePointer = 0;
            tr = driver.sequencer.tracks[freePointer];
            tr.keyOff();
            tr.channel.reset();
        }
    }
}

import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.*;
import flash.media.Sound;
import flash.net.*;
import flash.system.Security;

class MIDIPlayer {
    public  var voices:SiONPresetVoice;
    private var _tickPerClock:Number;
    private var _channels:Vector.<MIDIChannel> = new Vector.<MIDIChannel>(16);
    private var _pointers:Vector.<SMFTrackPointer> = new Vector.<SMFTrackPointer>();
    
    function MIDIPlayer() {
        driver = SiONDriver.mutex || new SiONDriver();
        voices = new SiONPresetVoice();
        MIDIChannel.midiVoiceList = voices["midi"];
        _createGMDrumSet();
        for (var i:int=0; i<16; i++) _channels[i] = new MIDIChannel(i);
    }
    
    public function play(smfData:SMFSequence) : void {
        _pointers.length = smfData.tracks.length;
        for (var i:int=0; i<_pointers.length; i++) {
            _pointers[i] = new SMFTrackPointer(smfData.tracks[i]);
        }
        
        SMFTrackPointer.tickPerClock = smfData.division/8;
        driver.setTimerInterruption(0.5, _onMIDIClock);
        driver.bpm = smfData.tempo;
        
        reset();
        driver.play("#EFFECT1{reverb};#EFFECT2{chorus};");
    }
    
    private function _createGMDrumSet() : void {
        var perc:Array = voices["valsound.percus"], tom:SiONVoice = new SiONVoice(), wave:Vector.<Number>;
        var mml:String = "@v128%6";
        for (var i:int=0; i<perc.length; i++) driver.setVoice(i, perc[i]);
        /*
        // bd
        wave = driver.render(mml+"v20@0o2c2");
        driver.setSamplerData(35, wave);
        driver.setSamplerData(36, wave);
        // sd
        driver.setSamplerData(37, driver.render(mml+"v20@26o4c2"));
        driver.setSamplerData(38, driver.render("#EFFECT{ws};@v128%6v16@30o3c2"));
        driver.setSamplerData(39, driver.render(mml+"v20@26o5g2"));
        driver.setSamplerData(40, driver.render("#EFFECT{ws};@v128%6v16@14o2g2"));
        // tom
        tom.param = [8,0,0,19,60,48,0,48,15,12,0,0,1,0,0,0,0,68,17,48,8,0,0,0,0,0,0,1,0,0,0,0,68,34,60,45,0,0,8,26,0,0,1,0,300,0,0,0,32,60,24,0,24,15,0,0,0,1,0,0,0,0,0];
        tom.setLPFEnvelop(100);
        driver.setVoice(64, tom);
        driver.setSamplerData(41, driver.render(mml+"v24@64o3c"));
        driver.setSamplerData(43, driver.render(mml+"v24@64o3e"));
        driver.setSamplerData(45, driver.render(mml+"v24@64o3g"));
        driver.setSamplerData(47, driver.render(mml+"v24@64o4c"));
        driver.setSamplerData(48, driver.render(mml+"v24@64o4g"));
        driver.setSamplerData(50, driver.render(mml+"v24@64o4b"));
        // hh
        driver.setSamplerData(42, driver.render(mml+"p2v6@17o4c"));
        driver.setSamplerData(44, driver.render(mml+"p2v6@15o4c"));
        driver.setSamplerData(46, driver.render(mml+"p2v6@24o5f1"));
        // cc
        driver.setSamplerData(49, driver.render(mml+"v16@7o5c1^1"));
        driver.setSamplerData(51, driver.render(mml+"v16@27o6f+1^1"));
        driver.setSamplerData(52, driver.render(mml+"v16@7o2g1^1"));
        driver.setSamplerData(55, driver.render(mml+"v16@7o5c1^1"));
        driver.setSamplerData(57, driver.render(mml+"v16@7o5f1^1"));
        */
        
        //percussion (load a drumset)
        Security.loadPolicyFile("http://www.dreamana.com/crossdomain.xml");
        
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function():void{ trace("IOError")});
        loader.load(new URLRequest("http://www.dreamana.com/lab/sion/JV1080.swf"));  
    }
    
    private function onLoadComplete(e:Event):void
    {
        var loaderInfo:LoaderInfo = e.currentTarget as LoaderInfo;
	var lib:Object = loaderInfo.content;
        for(var i:int=27; i < 88; ++i) {
	    var snd:Sound = lib.getInstance(GMStandard.percussion[i]) as Sound;
	    if(snd != null) driver.setSamplerSound(i, snd);
        }
    } 
    
    public function reset() : void {
        for (var i:int=0; i<16; i++) _channels[i].reset();
    }
    
    private function _onMIDIClock() : void {
        freeNoteOffTracks();
        var e:SMFEvent, pt:SMFTrackPointer;
        for each (pt in _pointers) {
            while (e = pt.getNextEvent()) {
                switch(e.type) {
                case 0x80: _channels[e.channel].noteOff(e.note); break;
                case 0x90: _channels[e.channel].noteOn(e.note, e.velocity); break;
                case 0xa0: _channels[e.channel].channelAfterTouch(e.value); break;
                case 0xb0: _channels[e.channel].controlChange(e.cc, e.value); break;
                case 0xc0: _channels[e.channel].programChange(e.value); break;
                case 0xd0: _channels[e.channel].channelAfterTouch(e.value); break;
                case 0xe0: _channels[e.channel].pitchBend(e.lsb | (e.msb<<7)); break;
                case 0x51: driver.bpm = 60000000/e.tempo; break;
                }
            }
        }
    }
}

class SMFTrackPointer {
    static public var tickPerClock:Number;
    public var smfSequence:Vector.<SMFEvent>, pointer:int=0, ticks:Number=0;
    function SMFTrackPointer(track:SMFTrack) { smfSequence = track.sequence; }
    public function getNextEvent() : SMFEvent {
        if (pointer >= smfSequence.length) return null;
        var e:SMFEvent = smfSequence[pointer];
        ticks += e.delta_time;
        if (ticks >= tickPerClock) {
            ticks -= (e.delta_time + tickPerClock);
            return null;
        }
        pointer++;
        return e;
    }
}

class MIDIChannel {
    use namespace _sion_internal;
    static public var midiVoiceList:Array;
    static private var _pbRate:Number = 1/8192*64;
    
    public var drumChannel:Boolean = false, mute:Boolean = false;
    public var volumes:Vector.<int>, exp:int, pan:int, centerPitch:int;
    public var programNum:int, pb:int, afterTouch:int, modulation:int;
    public var rpn:int, pbRange:int, fineTune:int, courseTune:int;
    private var _trackID:int;
    
    function MIDIChannel(channelNumber:int) {
        _trackID = channelNumber;
        drumChannel = (channelNumber == 9);
    }
    
    public function reset() : void {
        volumes = Vector.<int>([100, 0, 0, 0, 0, 0, 0, 0]);
        programNum = 0;
        exp = 128;
        pan = 64;
        pb = 0;
        afterTouch = 0;
        modulation = 0;
        rpn = 0;
        pbRange = 2;
        fineTune = 64;
        courseTune = 64;
    }
    
    public function noteOff(note:int) : void {
        if (mute) return;
        driver.noteOff(note, _trackID, 0, 0);
    }
    
    public function noteOn(note:int, vel:int) : void {
        var track:SiMMLTrack;
        if (mute) return;
        if (vel == 0) noteOff(note);
        else {
            if (drumChannel) track = driver.playSound(note, 0, 0, 0, _trackID);
            else track = driver.noteOn(note, midiVoiceList[programNum], 0, 0, 0, _trackID);
            track.noteShift  = courseTune - 64; // not available
            track.pitchShift = fineTune - 64;   // not available
            track.velocity = vel + afterTouch;
            track.expression = exp;
            track.channel.setAllStreamSendLevels(volumes);
            track.channel.pan = pan-64;
            track.channel.setPitchModulation(modulation);
            if (pb != 0) track.channel.pitch += pb * pbRange * _pbRate;
        }
    }
    
    public function controlChange(cc:int, value:int) : void {
        switch (cc) {
        case 1:  modulation = value; break;
        case 6:  dataEntry(value); break;
        case 7:  volumes[0] = value; break;
        case 11: pan = value; break;
        case 33: modulation = value; break;
        case 91: volumes[1] = value; break;
        case 93: volumes[2] = value; break;
        case 100: rpn = (rpn & 0xff00) | value;      break; // LSB
        case 101: rpn = (rpn & 0x00ff) | (value<<8); break; // MSB
        case 2: case 10:
            exp = value; 
            forEachTracks(function(tr:SiMMLTrack):void{tr.expression = exp;});
            break;
        }
        
        function dataEntry(value:int) : void {
            switch (rpn) {
            case 0x0000: pbRange    = value; break;
            case 0x0001: fineTune   = value; break;
            case 0x0002: courseTune = value; break;
            }
        }
    }
    
    public function programChange(pn:int) : void {
        programNum = pn;
    }
    
    public function channelAfterTouch(value:int) : void {
        if (mute) return;
        var atDiff:int = afterTouch - value;
        forEachTracks(function(tr:SiMMLTrack) : void { tr.velocity += atDiff; });
        afterTouch = value;
    }
    
    public function pitchBend(value:int) : void {
        var pitchDiff:int = (value - 8192 - pb) * pbRange * _pbRate;
        forEachTracks(function(tr:SiMMLTrack) : void { tr.channel.pitch += pitchDiff; });
        pb = value - 8192;
    }
    
    public function forEachTracks(func:Function) : void {
        // The tracks created by noteOn have an internal track id of "trackID | DRIVER_NOTE_ID_OFFSET".
        var internalTrackID:int = _trackID | SiMMLTrack.DRIVER_NOTE_ID_OFFSET;
        for each (var tr:SiMMLTrack in driver.sequencer.tracks) {
            if (tr.isActive && tr.trackID == internalTrackID) func(tr);
        }
    }
}




	import flash.utils.ByteArray;
	
	class SMFSequence
	{
		public var format:int;
		public var numTracks:int;
		public var division:int;
		public var tempo:int = 0;
		public var title:String = "";
		public var artist:String = "";
		public var signature_n:int;
		public var signature_d:int;
		public var length:int;
		
		public var tracks:Vector.<SMFTrack> = new Vector.<SMFTrack>();
		
		function SMFSequence(bytes:ByteArray)
		{
			bytes.position = 0;
			
			while(bytes.bytesAvailable > 0)
			{
				var type:String = bytes.readMultiByte(4, "us-ascii");
				switch(type)
				{
				case "MThd":	//ヘッダ
					bytes.position += 4;	//ヘッダのデータ長は常に00 00 00 06なのでスルー
					format = bytes.readUnsignedShort();
					numTracks = bytes.readUnsignedShort();
					division = bytes.readUnsignedShort();
					break;
				case "MTrk":	//トラック
					var len:uint = bytes.readUnsignedInt();
					var temp:ByteArray = new ByteArray();
					bytes.readBytes(temp, 0, len);
					var track:SMFTrack = new SMFTrack(this, temp);
					tracks.push(track);
					length = Math.max(length, track.length);
					break;
				default:
					return;
				}
			}
		}
		
		public function toString():String
		{
			var text:String = "format : "+format+" | numTracks : "+numTracks+" | division : "+division+"\n";
			text += "タイトル : "+title+" | 著作権表示 : "+artist+"\n";
			text += "拍子 : "+signature_d+"分の"+signature_n+"拍子 | BPM : "+tempo+" | length : "+length+"\n";
			
			text += "\n";
			
			for(var i:int = 0; i < tracks.length; i++)
			{
				text += "トラック"+i+" : "+tracks[i].toString() + "\n";
			}
			
			return text;
		}
	}

	class SMFTrack
	{
		public var parent:SMFSequence;
		public var sequence:Vector.<SMFEvent> = new Vector.<SMFEvent>();
		public var length:int;
		
		function SMFTrack(parent:SMFSequence, bytes:ByteArray)
		{
			this.parent = parent;
			
			var event:SMFEvent;
			var temp:int;
			var len:int;
			
			var type:int;
			var channel:int;
			
			var time:int;
			/*
			var readVariableLength:Function = function(time:uint = 0):uint
			{
				var temp:uint = bytes.readUnsignedByte();
				if(temp & 0x80) {return readVariableLength(time + (temp & 0x7F));}
				else {return time + (temp & 0x7F);}
			}
			*/
			var readVariableLength:Function = function(time:uint = 0):uint
			{
				var temp:uint = bytes.readUnsignedByte();
				if(temp & 0x80) {return readVariableLength((time << 7) + (temp & 0x7F));}
				else {return (time << 7) + (temp & 0x7F);}
			}
			
			main : while(bytes.bytesAvailable > 0)
			{
				event = new SMFEvent();
				event.delta_time = readVariableLength();
				time += event.delta_time;
				event.time = time;
				
				temp = bytes.readUnsignedByte();
				
				if(temp == 0xFF)
				{
					event.type = bytes.readUnsignedByte();
					len = readVariableLength();
					
					switch(event.type)
					{
					case 0x02:	//作者
						event.artist = bytes.readMultiByte(len, "Shift-JIS");
						parent.artist = event.artist;
						break;
					case 0x03:	//タイトル
						event.title = bytes.readMultiByte(len, "Shift-JIS");
						parent.title = event.title;
						break;
					case 0x2F:	//トラック終了
						break main;
					case 0x51:	//テンポ
						event.tempo = bytes.readUnsignedByte()*0x10000 + bytes.readUnsignedShort();
						if(parent.tempo == 0) {
							parent.tempo = 60000000 / event.tempo;
						}
						break;
					case 0x58:	//拍子
						parent.signature_n = bytes.readUnsignedByte();
						parent.signature_d = Math.pow(2, bytes.readUnsignedByte());
						bytes.position += 2;
						break;
					default:
						bytes.position += len;
						break;
					}
				}
				else if(temp == 0xF0 || temp == 0xF7)	//Sysx
				{
					event.type = temp;
					len = readVariableLength();
					event.sysx = new ByteArray();
					bytes.readBytes(event.sysx, 0, len);
				}
				else {
					if(temp & 0x80) {
						type = temp & 0xF0;
						channel = temp & 0x0F;
					}
					else {
						bytes.position--;
					}
					
					event.type = type;
					event.channel = channel;
					
					switch(type)
					{
					case 0x80:	//ノートオフ
						event.note = bytes.readUnsignedByte();
						event.velocity = bytes.readUnsignedByte();
						break;
					case 0x90:	//ノートオン
						event.note = bytes.readUnsignedByte();
						event.velocity = bytes.readUnsignedByte();
						break;
					case 0xA0:	//ポリフォニックキープレッシャー
						event.note = bytes.readUnsignedByte();
						event.value = bytes.readUnsignedByte();
						break;
					case 0xB0:	//コントロールチェンジ
						event.cc = bytes.readUnsignedByte();
						event.value = bytes.readUnsignedByte();
						break;
					case 0xC0:	//パッチチェンジ
						event.value = bytes.readUnsignedByte();
						break;
					case 0xD0:	//チャンネルプレッシャー
						event.value = bytes.readUnsignedByte();
						break;
					case 0xE0:	//ピッチベンド
						event.lsb = bytes.readUnsignedByte();
						event.msb = bytes.readUnsignedByte();
						break;
					}
				}
				sequence.push(event);
			}
			length = time;
		}
		
		public function toString():String
		{
			var text:String = length + "\n";
			
			for(var i:int = 0; i < sequence.length; i++)
			{
				if(sequence[i].toString() == "") {continue;}
				text += sequence[i].toString();
			}
			
			return text;
		}
	}

	dynamic class SMFEvent
	{
		public var delta_time:uint;	//相対時間
		public var time:uint;	//絶対時間
		public var type:int;
		
		public function toString():String
		{
			var text:String = "";
			//text = type.toString(16);
			//*
			switch(type)
			{
			case 0x90:
				if(this.velocity == 0) {break;}
				text += "o" + int(this.note / 12 - 1);
				text += ["c", "c+", "d", "d+", "e", "f", "f+", "g", "g+", "a", "a+", "b"][this.note % 12]
				text += " ";//+this.velocity;
				break;
			case 0xB0:
				text += "CC#" + this.cc +" "+this.value + " ";
				break;
			case 0xC0:
				text += "楽器変更 " + this.value + " ";
				break;
			case 0xF0:
			case 0xF7:
				text += "Sysx : ";
				for(var i:int = 0; i < this.sysx.length; i++) {
					text += this.sysx[i].toString(16)+" ";
				}
				break;
			}
			
			return text;
		}
	}


class GMStandard
{
	public static const percussion:Array = new Array();
	{
		//GM1
		percussion[35] = "BassDrum2";
		percussion[36] = "BassDrum1";
		percussion[37] = "SideStick";
		percussion[38] = "SnareDrum1";
		percussion[39] = "HandClap";
		percussion[40] = "SnareDrum2";
		percussion[41] = "LowTom2";
		percussion[42] = "ClosedHiHat";
		percussion[43] = "LowTom1";
		percussion[44] = "PedalHiHat";
		percussion[45] = "MidTom2";
		percussion[46] = "OpenHiHat";
		percussion[47] = "MidTom1";
		percussion[48] = "HighTom2";
		percussion[49] = "CrashCymbal1";
		percussion[50] = "HighTom1";
		percussion[51] = "RideCymbal1";
		percussion[52] = "ChineseCymbal";
		percussion[53] = "RideBell";
		percussion[54] = "Tambourine";
		percussion[55] = "SplashCymbal"; 
		percussion[56] = "Cowbell";
		percussion[57] = "CrashCymbal2";
		percussion[58] = "VibraSlap";
		percussion[59] = "RideCymbal2";
		percussion[60] = "HighBongo";
		percussion[61] = "LowBongo";
		percussion[62] = "MuteHighConga";
		percussion[63] = "OpenHighConga";
		percussion[64] = "LowConga";
		percussion[65] = "HighTimbale";
		percussion[66] = "LowTimbale";
		percussion[67] = "HighAgogo";
		percussion[68] = "LowAgogo";
		percussion[69] = "Cabasa";
		percussion[70] = "Maracas";
		percussion[71] = "ShortWhistle";
		percussion[72] = "LongWhistle";
		percussion[73] = "ShortGuiro";
		percussion[74] = "LongGuiro";
		percussion[75] = "Claves";
		percussion[76] = "HighWoodBlock";
		percussion[77] = "LowWoodBlock";
		percussion[78] = "MuteCuica";
		percussion[79] = "OpenCuica";
		percussion[80] = "MuteTriangle";
		percussion[81] = "OpenTriangle";
		
		//GM2
		percussion[27] = "HighQ";
		percussion[28] = "Slap";
		percussion[29] = "ScratchPush";
		percussion[30] = "ScratchPull";
		percussion[31] = "Sticks";
		percussion[32] = "SquareClick";
		percussion[33] = "MetronomeClick";
		percussion[34] = "MetronomeBell";
		percussion[34] = "MetronomeBell";
		
		percussion[82] = "Shaker";
		percussion[83] = "JingleBell";
		percussion[84] = "BellTree";
		percussion[85] = "Castanets";
		percussion[86] = "MuteSurdo";
		percussion[87] = "OpenSurdo";
	}
}
	
	class SMFBinary
	{
		public static const data:String = "eNrtW+tXVFl2P6hgp3CC083q8YFYCkiBPH1ACxe8BSUWjegVdaSVNqAXR+0WaLS7r4yRReEj050soKpoAbP8Nh9nLbU1mSz7Qx6dx8r8EUGnk09ZWVnJl8kn89vncevWrSpQhFa01urt3mc/z9n77HNOXe3"
		 + "2o+dMxlgWy2A/zZhtPzr4CUZ/YM9W5jT39BVf9p7pv9jrPd1z5hP2bAXj7P4+8/Mzl/sHvUcHOTsr88jlnsHL7NlHUGDPOletWrHuHfbs8MrVnqdjEK9orY6X/YEzdyQyV7buKI7njtziujvjub8hpj+ZV/+OJPYrW3e63H5Huk3V7ilXMrH+3N9ho"
		 + "e+0DPZe/rT30iV2b7XJ7mUyds8/zO5dy2B/W8ju9WKIvN3LWvP1xlmmZwLYeOFn64FzZ9ne7lnWWDXLGgB1gFrATkA5oHDzLHs3d7yQMW6zybTGNzHLxluBC3VtfCvTSGe8xNTGS0BvMkcGpCIG7Hre+EYQG7kkpIPjk5Kba0AYIELrbIJHyofnfDh"
		 + "QuBC4SKco2ngRIpXCvBR0PkUSihhQJOGYJIiUj0hCMrJrvNg8Ad/5syzgny3bVzvrbbHGi+XKKM5WrkirYeNFFM+OA+N8kxR9SFUOUo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