public byte[] toDJZ20() { ////文件结构 ////*文件开始*// //u32 FileSize ; //文件大小 //u32 EndTime ; //结束时间 //u32 NoteCount ; //音符数量 //Note* Notes ; //音符数据 //u32 MetaCount ; //控制数量 //Meta* Controls ; //控制数据 ////*文件结束*// ////文件字节流按照 高位存高字节 低位存低字节的顺序 ////音符结构体 (就是游戏中落下的块) //typedef struct { //u32 Time ; //时间 单位 ms , 该音符在什么时间激发 //u8 Line ; //游戏中的轨道:将由编辑器编辑 //u8 Data ; //发音 (就是MIDI事件的发音) //}Note; ////控制结构体 (就是游戏中落下的块) //typedef struct { //u32 Time ; //时间 单位 ms , 在什么时间激发 //u8 Type ; //类型 //u32 Data ; //数据 //}Meta; EventComparerDJZTime ec = new EventComparerDJZTime(); Events.Sort(ec); Controls.Sort(ec); Int32 FileSize = 4 + 4 + 4 + Events.Count * 6 + 4 + Controls.Count * 9; byte[] data = new byte[FileSize]; int P = 0; Midi.write32(data, P, (Int32)FileSize); P += 4; //文件大小 Midi.write32(data, P, (Int32)EndTime); P += 4; //结束时间 Midi.write32(data, P, (Int32)Events.Count); P += 4; //音符数量 for (int i = 0; i < Events.Count; i++) //音符数据序列 { Midi.write32(data, P, (Int32)(((EventDJZ)Events[i]).time)); P += 4; Midi.write8(data, P, ((EventDJZ)Events[i]).pos); P += 1; Midi.write8(data, P, ((EventDJZ)Events[i]).note); P += 1; } Midi.write32(data, P, (Int32)Controls.Count); P += 4; //控制数量 for (int i = 0; i < Controls.Count; i++) //控制数据序列 { Midi.write32(data, P, (Int32)(((EventDJZ)Controls[i]).time)); P += 4; Midi.write8(data, P, ((EventDJZ)Controls[i]).note); P += 1; Midi.write32(data, P, ((EventDJZ)Controls[i]).metadata); P += 4; } return(data); }
public byte[] toDJZ10() { ////文件结构 ////*文件开始*// //u32 FileSize ; //文件大小 //u32 BPM ; //歌曲速度 (Beat Per Min 拍/分钟) //u32 NoteCount ; //音符数量 //Node* Notes ; //音符数据 ////*文件结束*// ////文件字节流按照 高位存高字节 低位存低字节的顺序 ////音符结构体 (就是游戏中落下的块) //typedef struct { //u32 Time ; //时间 单位 ms , 该音符在什么时间激发 //u8 Line ; //游戏中的轨道 :将由编辑器编辑 //u8 Data ; //发音 (就是MIDI事件的发音) //}Node; EventComparerDJZTime ec = new EventComparerDJZTime(); Events.Sort(ec); Int32 FileSize = 4 + 4 + 4 + Events.Count * 6; byte[] data = new byte[FileSize]; int P = 0; Midi.write32(data, P, (Int32)FileSize); P += 4; //文件大小 Midi.write32(data, P, (Int32)BPM); P += 4; //歌曲速度 (Beat Per Min 拍/分钟) Midi.write32(data, P, (Int32)Events.Count); P += 4; //音符数量 for (int i = 0; i < Events.Count; i++) //音符数据序列 { Midi.write32(data, P, (Int32)(((EventDJZ)Events[i]).time)); P += 4; Midi.write8(data, P, ((EventDJZ)Events[i]).pos); P += 1; Midi.write8(data, P, ((EventDJZ)Events[i]).note); P += 1; //Console.WriteLine("Note[" + i + "].time = " + (Int32)(((Event)Events[i]).time)); } return(data); }
public string toBMS(Boolean isOld, String mainSong) { // 01 = 背景NOTE音。 // // 03 = 0~255(0h~FFh)整数BPM变化。 // // 04 = 改变BGA的图片索引。 // 06 = 改变POOR的图片索引。 // 07 = 改变Layer的图片索引。 // // 08 = 改变的BPM索引。表示小数的BPM变化或者大于255的BPM。(前方定义的 #BPMXX) // 09 = STOP停止的时间索引。(前方定义的 #STOPXX) // // 11 = 1P KEY 1 // 12 = 1P KEY 2 // 13 = 1P KEY 3 // 14 = 1P KEY 4 // 15 = 1P KEY 5 // 16 = 1P KEY SC // 18 = 1P KEY 6 // 19 = 1P KEY 7 // // 21 = 2P KEY 1 // 22 = 2P KEY 2 // 23 = 2P KEY 3 // 24 = 2P KEY 4 // 25 = 2P KEY 5 // 26 = 2P KEY SC // 28 = 2P KEY 6 // 29 = 2P KEY 7 // // 51 = 1P LONG KEY 1 // 52 = 1P LONG KEY 2 // 53 = 1P LONG KEY 3 // 54 = 1P LONG KEY 4 // 55 = 1P LONG KEY 5 // 56 = 1P LONG KEY SC // 58 = 1P LONG KEY 6 // 59 = 1P LONG KEY 7 // // 61 = 2P LONG KEY 1 // 62 = 2P LONG KEY 2 // 63 = 2P LONG KEY 3 // 64 = 2P LONG KEY 4 // 65 = 2P LONG KEY 5 // 66 = 2P LONG KEY SC // 68 = 2P LONG KEY 6 // 69 = 2P LONG KEY 7 // *---------------------- HEADER FIELD // // #PLAYER 2 // #GENRE 123 // #TITLE 123 // #ARTIST 123 // #BPM 120 // #PLAYLEVEL 1 // #RANK 3 // #TOTAL 123 // #VOLWAV 123 // #STAGEFILE 123 // // #WAV01 Ba_b_4.wav // #WAV02 Ba_b_8.wav // #WAV03 Ba_c#_4.wav // // #BMP00 123 // #BMP01 back.bmp // #BMP02 end01.bmp // #BMP03 Fade01.bmp // // // #BPM01 256 // // #STOP01 123 // // // // // *---------------------- MAIN DATA FIELD // // #00008:0001 // #00009:00010000 // #00022:00010000 // #00061:01 // // #00161:01 EventComparerDJZTime ecT = new EventComparerDJZTime(); EventComparerDJZChannelProgramNote ecCPN = new EventComparerDJZChannelProgramNote(); EventComparerDJZMetaBPM ecBPM = new EventComparerDJZMetaBPM(); Events.Sort(ecT); Controls.Sort(ecT); Hashtable WAV = new Hashtable(); Hashtable BPM = new Hashtable(); int HDBPMIndex = 1; for (int i = 0; i < Controls.Count; i++) { switch (((EventDJZ)Controls[i]).note) { case EventDJZ.CONTROL_BPM: if (!haveValue(BPM, (EventDJZ)Controls[i], ecBPM)) { try { if (isOld) { BPM.Add((EventDJZ)Controls[i], valTo00FF(HDBPMIndex)); } else { BPM.Add((EventDJZ)Controls[i], valTo00ZZ(HDBPMIndex)); } HDBPMIndex++; } catch (Exception err) { Util.println(err.Message + " Out Of Head Max ! " + HDBPMIndex); } } break; } } int HDWAVIndex = 2; for (int i = 0; i < Events.Count; i++) { if (!haveValue(WAV, (EventDJZ)Events[i], ecCPN)) { try { if (isOld) { WAV.Add((EventDJZ)Events[i], valTo00FF(HDWAVIndex)); } else { WAV.Add((EventDJZ)Events[i], valTo00ZZ(HDWAVIndex)); } HDWAVIndex++; } catch (Exception err) { Util.println(err.Message + " Out Of Head Max ! " + HDWAVIndex); } } } String str = ""; String ret = "\r\n"; str += ret; str += "*---------------------- HEADER FIELD" + ret; str += ret; str += "#PLAYER 2" + ret; str += "#GENRE WAZA" + ret; str += "#TITLE " + ret; str += "#ARTIST " + ret; str += "#BPM 120" + ret; str += "#PLAYLEVEL 1" + ret; str += "#RANK " + ret; str += "#TOTAL " + Events.Count + ret; str += "#STAGEFILE " + ret; str += ret; str += "#WAV01 " + mainSong + ret; IDictionaryEnumerator ide_wav = WAV.GetEnumerator(); ide_wav.Reset(); while (ide_wav.MoveNext()) { String wav = "c" + ((EventDJZ)ide_wav.Key).channel.ToString("D2") + "p" + ((EventDJZ)ide_wav.Key).program.ToString("D3") + "n" + ((EventDJZ)ide_wav.Key).note.ToString("D3") + ".mid"; str += "#WAV" + ((String)ide_wav.Value) + " " + wav + ret; } str += ret; IDictionaryEnumerator ide_bpm = BPM.GetEnumerator(); ide_bpm.Reset(); while (ide_bpm.MoveNext()) { float value = ((float)((EventDJZ)ide_bpm.Key).BPM1000) / 1000; String bpm = value.ToString("F"); str += "#BPM" + ((String)ide_bpm.Value) + " " + bpm + ret; } str += ret; str += "*---------------------- MAIN DATA FIELD" + ret; str += ret; str += "#00001:" + "01" + ret; int fulldiv = curDJZ.midi.header.Division * 4; int fullnote = 0; while (true) { // bpm String LineBPM = setKey(Controls, fullnote, fulldiv, BPM, ecBPM, 0); if (LineBPM != "") { str += "#" + fullnote.ToString("D3") + "08:" + LineBPM + ret; } // 1p String Line1PKeySC = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 0); if (Line1PKeySC != "") { str += "#" + fullnote.ToString("D3") + "16:" + Line1PKeySC + ret; } String Line1PKey1 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 1); if (Line1PKey1 != "") { str += "#" + fullnote.ToString("D3") + "11:" + Line1PKey1 + ret; } String Line1PKey2 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 2); if (Line1PKey2 != "") { str += "#" + fullnote.ToString("D3") + "12:" + Line1PKey2 + ret; } String Line1PKey3 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 3); if (Line1PKey3 != "") { str += "#" + fullnote.ToString("D3") + "13:" + Line1PKey3 + ret; } String Line1PKey4 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 4); if (Line1PKey4 != "") { str += "#" + fullnote.ToString("D3") + "14:" + Line1PKey4 + ret; } String Line1PKey5 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 5); if (Line1PKey5 != "") { str += "#" + fullnote.ToString("D3") + "15:" + Line1PKey5 + ret; } String Line1PKey6 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 6); if (Line1PKey6 != "") { str += "#" + fullnote.ToString("D3") + "18:" + Line1PKey6 + ret; } String Line1PKey7 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 7); if (Line1PKey7 != "") { str += "#" + fullnote.ToString("D3") + "19:" + Line1PKey7 + ret; } // 2p String Line2PKey1 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 8); if (Line2PKey1 != "") { str += "#" + fullnote.ToString("D3") + "21:" + Line2PKey1 + ret; } String Line2PKey2 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 9); if (Line2PKey2 != "") { str += "#" + fullnote.ToString("D3") + "22:" + Line2PKey2 + ret; } String Line2PKey3 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 10); if (Line2PKey3 != "") { str += "#" + fullnote.ToString("D3") + "23:" + Line2PKey3 + ret; } String Line2PKey4 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 11); if (Line2PKey4 != "") { str += "#" + fullnote.ToString("D3") + "24:" + Line2PKey4 + ret; } String Line2PKey5 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 12); if (Line2PKey5 != "") { str += "#" + fullnote.ToString("D3") + "25:" + Line2PKey5 + ret; } String Line2PKey6 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 13); if (Line2PKey6 != "") { str += "#" + fullnote.ToString("D3") + "28:" + Line2PKey6 + ret; } String Line2PKey7 = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 14); if (Line2PKey7 != "") { str += "#" + fullnote.ToString("D3") + "29:" + Line2PKey7 + ret; } String Line2PKeySC = setKey(Events, fullnote, fulldiv, WAV, ecCPN, 15); if (Line2PKeySC != "") { str += "#" + fullnote.ToString("D3") + "26:" + Line2PKeySC + ret; } str += ret; fullnote++; if (fullnote > 999) { break; } if (Controls.Count <= 0 && Events.Count <= 0) { break; } } return(str); }