- Timestamp:
- 01/17/11 00:17:49 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/flmml/trunk/src/com/txt_nifty/sketch/flmml/MML.as
r38691 r38797 28 28 protected var m_beforeNote:int; 29 29 protected var m_portamento:int; 30 protected var m_usingPoly:Boolean; 31 protected var m_polyVoice:int; 32 protected var m_polyForce:Boolean; 33 protected var m_metaTitle:String; 34 protected var m_metaArtist:String; 35 protected var m_metaCoding:String; 36 protected var m_metaComment:String; 30 37 protected static var MAX_PIPE:int = 3; 31 38 protected static var MAX_SYNCSOURCE:int = 3; 39 protected static var MAX_POLYVOICE:int = 64; 32 40 33 41 public function MML() { … … 210 218 case 'p': // Pan 211 219 next(); 212 o = getUInt(64); 213 if (o < 1) o = 1; 214 if (o > 127) o = 127; 215 m_tracks[m_trackNo].recPan(o); 220 if (getChar() == 'l') { // poly mode 221 next(); 222 o = getUInt(m_polyVoice); 223 o = Math.max(0, Math.min(m_polyVoice, o)); 224 m_tracks[m_trackNo].recPoly(o); 225 } 226 else { 227 o = getUInt(64); 228 if (o < 1) o = 1; 229 if (o > 127) o = 127; 230 m_tracks[m_trackNo].recPan(o); 231 } 216 232 break; 217 233 case '\'': // formant filter … … 480 496 case "q": // gate time (rate) 481 497 m_gate = getUInt(m_gate); 482 m_tracks[m_trackNo].recGate( m_gate / m_maxGate);498 m_tracks[m_trackNo].recGate(Number(m_gate) / Number(m_maxGate)); 483 499 break; 484 500 case "<" : // octave shift … … 510 526 warning(MWarning.UNKNOWN_COMMAND, c + c0); 511 527 break; 528 case '[': 529 m_tracks[m_trackNo].recChordStart(); 530 break; 531 case ']': 532 m_tracks[m_trackNo].recChordEnd(); 533 break; 512 534 default: 513 535 { … … 757 779 protected function processMacro():void { 758 780 var i:int; 759 // OCTAVE REVERSE 781 var matched:Array; 782 // OCTAVE REVERSE 760 783 var exp:RegExp = /^#OCTAVE\s+REVERSE\s*$/m; 761 784 if (m_string.match(exp)) { … … 769 792 m_velDir = false; 770 793 } 794 // meta informations 795 { 796 m_metaTitle = findMetaDesc("TITLE" ); // #TITLE 797 m_metaArtist = findMetaDesc("ARTIST" ); // #ARTIST 798 m_metaComment = findMetaDesc("COMMENT"); // #COMMENT 799 m_metaCoding = findMetaDesc("CODING" ); // #CODING 800 findMetaDesc("PRAGMA"); // #PRAGMA 801 } 802 // POLY MODE 803 { 804 var usePoly:String = findMetaDesc("USING\\s+POLY"); 805 usePoly = usePoly.replace("\r", ""); 806 usePoly = usePoly.replace("\n", " "); 807 usePoly = usePoly.toLowerCase(); 808 if (usePoly.length > 0) { 809 var ss:Array = usePoly.split(" "); 810 if (ss.length < 1) { 811 m_usingPoly = false; 812 } 813 else { 814 m_usingPoly = true; 815 m_polyVoice = Math.min(Math.max(1, parseInt(ss[0])), MAX_POLYVOICE); // 1~MAX_POLYVOICE 816 } 817 for (i = 1; i < ss.length; i++) { 818 if (ss[i] == "force") { 819 m_polyForce = true; 820 } 821 } 822 if (m_polyVoice <= 1) { 823 m_usingPoly = false; 824 m_polyForce = false; 825 } 826 // trace("using poly = " + m_usingPoly + ", max voice = " + m_polyVoice + ", force = " + m_polyForce); 827 } 828 } 771 829 // GB WAVE (ex. "#WAV10 0,0123456789abcdeffedcba9876543210") 772 830 { 773 831 exp = /^#WAV10\s.*$/gm; 774 var matched:Array= m_string.match(exp);832 matched = m_string.match(exp); 775 833 if (matched) { 776 834 for(i = 0; i < matched.length; i++) { … … 935 993 } 936 994 } 937 995 996 // 指定されたメタ記述を引き抜いてくる 997 protected function findMetaDesc(sectionName:String):String { 998 var i:int; 999 var matched:Array; 1000 var mm:Array; 1001 var e1:RegExp; 1002 var e2:RegExp; 1003 var tt:String = ""; 1004 1005 e1 = new RegExp("^#" + sectionName + "(\\s*|\\s+(.*))$", "gm"); // global multi-line 1006 e2 = new RegExp("^#" + sectionName + "(\\s*|\\s+(.*))$", "m"); // multi-line 1007 1008 matched = m_string.match(e1); 1009 if (matched) { 1010 m_string = m_string.replace(e1, ""); 1011 for(i = 0; i < matched.length; i++) { 1012 mm = matched[i].match(e2); 1013 if (mm.length >= 3) { 1014 tt += mm[2]; 1015 if (i + 1 < matched.length) { 1016 tt += "\r\n"; 1017 } 1018 } 1019 } 1020 // trace(sectionName + " = " + tt); 1021 } 1022 return tt; 1023 } 1024 938 1025 protected function processComment(str:String):void { 939 1026 m_string = str; … … 1109 1196 m_beforeNote = 0; 1110 1197 m_portamento = 0; 1111 1198 m_usingPoly = false; 1199 m_polyVoice = 1; 1200 m_polyForce = false; 1201 1202 m_metaTitle = ""; 1203 m_metaArtist = ""; 1204 m_metaCoding = ""; 1205 m_metaComment = ""; 1206 1112 1207 processComment(str); 1113 1208 //trace(m_string+"\n\n"); … … 1130 1225 for(var i:int = MTrack.TEMPO_TRACK; i < m_tracks.length; i++) { 1131 1226 if (i > MTrack.TEMPO_TRACK) { 1227 if (m_usingPoly && (m_polyForce || m_tracks[i].findPoly())) { 1228 m_tracks[i].usingPoly(m_polyVoice); 1229 } 1132 1230 m_tracks[i].recRestMSec(2000); 1133 1231 m_tracks[i].recClose(); … … 1187 1285 return m_sequencer.getNowTimeStr(); 1188 1286 } 1287 public function getVoiceCount():int { 1288 var i:int; 1289 var c:int = 0; 1290 for (i = 0; i < m_tracks.length; i++) { 1291 c += m_tracks[i].getVoiceCount(); 1292 } 1293 return c; 1294 } 1295 public function getMetaTitle():String { 1296 return m_metaTitle; 1297 } 1298 public function getMetaComment():String { 1299 return m_metaComment; 1300 } 1301 public function getMetaArtist():String { 1302 return m_metaArtist; 1303 } 1304 public function getMetaCoding():String { 1305 return m_metaCoding; 1306 } 1189 1307 } 1190 1308 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)