public static void Put(Tone @Tone, ref string Buffer) { if (Tone.IsValid()) { var Header = String.Format("@{0}", Tone.Number) + Put(Tone.AL) + Put(Tone.FB) + String.Format(" = {0}", Tone.Name) + "\n"; var Op0 = Put(Tone.aOp[0]) + "\n"; var Op1 = Put(Tone.aOp[1]) + "\n"; var Op2 = Put(Tone.aOp[2]) + "\n"; var Op3 = Put(Tone.aOp[3]) + "\n"; Buffer += Header + Op0 + Op1 + Op2 + Op3 + "\n"; } }
public static void Put(Tone @Tone, ref string Buffer) { if (Tone.IsValid()) { var Entry = " " + String.Format("@{0}:{{", Tone.Number) + "\n"; var Header = " " + Put(Tone.FB) + Put(Tone.AL).TrimEnd(',') + "\n"; var Op0 = " " + Put(Tone.aOp[0]) + "\n"; var Op1 = " " + Put(Tone.aOp[1]) + "\n"; var Op2 = " " + Put(Tone.aOp[2]) + "\n"; var Op3 = " " + Put(Tone.aOp[3]) + String.Format(",\"{0}\"}}", Tone.Name) + "\n"; Buffer += Entry + Header + Op0 + Op1 + Op2 + Op3 + "\n"; } }
public static void Put(Tone @Tone, ref string Buffer) { if (Tone.IsValid()) { var Name = String.Format("({0})", Tone.Name) + "\n"; var Header = "'@ " + String.Format("FA {0}", Tone.Number) + "\n"; var Op0 = "'@ " + Put(Tone.aOp[0]) + "\n"; var Op1 = "'@ " + Put(Tone.aOp[1]) + "\n"; var Op2 = "'@ " + Put(Tone.aOp[2]) + "\n"; var Op3 = "'@ " + Put(Tone.aOp[3]) + "\n"; var Footer = "'@ " + Put(Tone.AL) + Put(Tone.FB).TrimEnd(',') + "\n"; Buffer += Name + Header + Op0 + Op1 + Op2 + Op3 + Footer + "\n"; } }
public static void Put(Tone @Tone, ref byte[] Buffer) { if (Tone.IsValid()) { int o = Tone.Number * PutLength(); Buffer[o + (int)ePut.Void] = 0; Buffer[o + (int)ePut.DTML0] = (byte)((Tone.aOp[0].DT << 4) | Tone.aOp[0].ML); Buffer[o + (int)ePut.DTML1] = (byte)((Tone.aOp[1].DT << 4) | Tone.aOp[1].ML); Buffer[o + (int)ePut.DTML2] = (byte)((Tone.aOp[2].DT << 4) | Tone.aOp[2].ML); Buffer[o + (int)ePut.DTML3] = (byte)((Tone.aOp[3].DT << 4) | Tone.aOp[3].ML); Buffer[o + (int)ePut.TL0] = (byte)Tone.aOp[0].TL; Buffer[o + (int)ePut.TL1] = (byte)Tone.aOp[1].TL; Buffer[o + (int)ePut.TL2] = (byte)Tone.aOp[2].TL; Buffer[o + (int)ePut.TL3] = (byte)Tone.aOp[3].TL; Buffer[o + (int)ePut.KSAR0] = (byte)((Tone.aOp[0].KS << 6) | Tone.aOp[0].AR); Buffer[o + (int)ePut.KSAR1] = (byte)((Tone.aOp[1].KS << 6) | Tone.aOp[1].AR); Buffer[o + (int)ePut.KSAR2] = (byte)((Tone.aOp[2].KS << 6) | Tone.aOp[2].AR); Buffer[o + (int)ePut.KSAR3] = (byte)((Tone.aOp[3].KS << 6) | Tone.aOp[3].AR); Buffer[o + (int)ePut.DR0] = (byte)Tone.aOp[0].DR; Buffer[o + (int)ePut.DR1] = (byte)Tone.aOp[1].DR; Buffer[o + (int)ePut.DR2] = (byte)Tone.aOp[2].DR; Buffer[o + (int)ePut.DR3] = (byte)Tone.aOp[3].DR; Buffer[o + (int)ePut.SR0] = (byte)Tone.aOp[0].SR; Buffer[o + (int)ePut.SR1] = (byte)Tone.aOp[1].SR; Buffer[o + (int)ePut.SR2] = (byte)Tone.aOp[2].SR; Buffer[o + (int)ePut.SR3] = (byte)Tone.aOp[3].SR; Buffer[o + (int)ePut.SLRR0] = (byte)((Tone.aOp[0].SL << 4) | Tone.aOp[0].RR); Buffer[o + (int)ePut.SLRR1] = (byte)((Tone.aOp[1].SL << 4) | Tone.aOp[1].RR); Buffer[o + (int)ePut.SLRR2] = (byte)((Tone.aOp[2].SL << 4) | Tone.aOp[2].RR); Buffer[o + (int)ePut.SLRR3] = (byte)((Tone.aOp[3].SL << 4) | Tone.aOp[3].RR); Buffer[o + (int)ePut.FBAL] = (byte)((Tone.FB << 3) | Tone.AL); Buffer[o + (int)ePut.Name0] = (byte)((Tone.Name.Length > 0) ? Tone.Name[0] : 0); Buffer[o + (int)ePut.Name1] = (byte)((Tone.Name.Length > 1) ? Tone.Name[1] : 0); Buffer[o + (int)ePut.Name2] = (byte)((Tone.Name.Length > 2) ? Tone.Name[2] : 0); Buffer[o + (int)ePut.Name3] = (byte)((Tone.Name.Length > 3) ? Tone.Name[3] : 0); Buffer[o + (int)ePut.Name4] = (byte)((Tone.Name.Length > 4) ? Tone.Name[4] : 0); Buffer[o + (int)ePut.Name5] = (byte)((Tone.Name.Length > 5) ? Tone.Name[5] : 0); } }
public static void Put(Tone @Tone, ref byte[] Buffer) { if (Tone.IsValid() && Tone.Number < ToneLength()) { int o = HeadLength() + (Tone.Number * PutLength()); Buffer[o + (int)ePut.AR0] = (byte)Tone.aOp[0].AR; Buffer[o + (int)ePut.AR1] = (byte)Tone.aOp[1].AR; Buffer[o + (int)ePut.AR2] = (byte)Tone.aOp[2].AR; Buffer[o + (int)ePut.AR3] = (byte)Tone.aOp[3].AR; Buffer[o + (int)ePut.DR0] = (byte)Tone.aOp[0].DR; Buffer[o + (int)ePut.DR1] = (byte)Tone.aOp[1].DR; Buffer[o + (int)ePut.DR2] = (byte)Tone.aOp[2].DR; Buffer[o + (int)ePut.DR3] = (byte)Tone.aOp[3].DR; Buffer[o + (int)ePut.SR0] = (byte)Tone.aOp[0].SR; Buffer[o + (int)ePut.SR1] = (byte)Tone.aOp[1].SR; Buffer[o + (int)ePut.SR2] = (byte)Tone.aOp[2].SR; Buffer[o + (int)ePut.SR3] = (byte)Tone.aOp[3].SR; Buffer[o + (int)ePut.RR0] = (byte)Tone.aOp[0].RR; Buffer[o + (int)ePut.RR1] = (byte)Tone.aOp[1].RR; Buffer[o + (int)ePut.RR2] = (byte)Tone.aOp[2].RR; Buffer[o + (int)ePut.RR3] = (byte)Tone.aOp[3].RR; Buffer[o + (int)ePut.SL0] = (byte)Tone.aOp[0].SL; Buffer[o + (int)ePut.SL1] = (byte)Tone.aOp[1].SL; Buffer[o + (int)ePut.SL2] = (byte)Tone.aOp[2].SL; Buffer[o + (int)ePut.SL3] = (byte)Tone.aOp[3].SL; Buffer[o + (int)ePut.TL0] = (byte)Tone.aOp[0].TL; Buffer[o + (int)ePut.TL1] = (byte)Tone.aOp[1].TL; Buffer[o + (int)ePut.TL2] = (byte)Tone.aOp[2].TL; Buffer[o + (int)ePut.TL3] = (byte)Tone.aOp[3].TL; Buffer[o + (int)ePut.KS0] = (byte)Tone.aOp[0].KS; Buffer[o + (int)ePut.KS1] = (byte)Tone.aOp[1].KS; Buffer[o + (int)ePut.KS2] = (byte)Tone.aOp[2].KS; Buffer[o + (int)ePut.KS3] = (byte)Tone.aOp[3].KS; Buffer[o + (int)ePut.ML0] = (byte)Tone.aOp[0].ML; Buffer[o + (int)ePut.ML1] = (byte)Tone.aOp[1].ML; Buffer[o + (int)ePut.ML2] = (byte)Tone.aOp[2].ML; Buffer[o + (int)ePut.ML3] = (byte)Tone.aOp[3].ML; Buffer[o + (int)ePut.DT1_0] = (byte)Tone.aOp[0].DT; Buffer[o + (int)ePut.DT1_1] = (byte)Tone.aOp[1].DT; Buffer[o + (int)ePut.DT1_2] = (byte)Tone.aOp[2].DT; Buffer[o + (int)ePut.DT1_3] = (byte)Tone.aOp[3].DT; Buffer[o + (int)ePut.DT2_0] = (byte)Tone.aOp[0].DT2; Buffer[o + (int)ePut.DT2_1] = (byte)Tone.aOp[1].DT2; Buffer[o + (int)ePut.DT2_2] = (byte)Tone.aOp[2].DT2; Buffer[o + (int)ePut.DT2_3] = (byte)Tone.aOp[3].DT2; Buffer[o + (int)ePut.AM0] = (byte)Tone.aOp[0].AM; Buffer[o + (int)ePut.AM1] = (byte)Tone.aOp[1].AM; Buffer[o + (int)ePut.AM2] = (byte)Tone.aOp[2].AM; Buffer[o + (int)ePut.AM3] = (byte)Tone.aOp[3].AM; Buffer[o + (int)ePut.AL] = (byte)Tone.AL; Buffer[o + (int)ePut.FB] = (byte)Tone.FB; Buffer[o + (int)ePut.Mask] = 0xf << 3; if (String.IsNullOrWhiteSpace(Tone.Name)) { Tone.Name = Tone.Number.ToString(); } Buffer[o + (int)ePut.Name0] = (byte)((Tone.Name.Length > 0) ? Tone.Name[0] : 0); Buffer[o + (int)ePut.Name1] = (byte)((Tone.Name.Length > 1) ? Tone.Name[1] : 0); Buffer[o + (int)ePut.Name2] = (byte)((Tone.Name.Length > 2) ? Tone.Name[2] : 0); Buffer[o + (int)ePut.Name3] = (byte)((Tone.Name.Length > 3) ? Tone.Name[3] : 0); Buffer[o + (int)ePut.Name4] = (byte)((Tone.Name.Length > 4) ? Tone.Name[4] : 0); Buffer[o + (int)ePut.Name5] = (byte)((Tone.Name.Length > 5) ? Tone.Name[5] : 0); Buffer[o + (int)ePut.Name6] = (byte)((Tone.Name.Length > 6) ? Tone.Name[6] : 0); Buffer[o + (int)ePut.Name7] = (byte)((Tone.Name.Length > 7) ? Tone.Name[7] : 0); Buffer[o + (int)ePut.Name8] = (byte)((Tone.Name.Length > 8) ? Tone.Name[8] : 0); Buffer[o + (int)ePut.Name9] = (byte)((Tone.Name.Length > 9) ? Tone.Name[9] : 0); Buffer[o + (int)ePut.Name10] = (byte)((Tone.Name.Length > 10) ? Tone.Name[10] : 0); Buffer[o + (int)ePut.Name11] = (byte)((Tone.Name.Length > 11) ? Tone.Name[11] : 0); Buffer[o + (int)ePut.Name12] = (byte)((Tone.Name.Length > 12) ? Tone.Name[12] : 0); Buffer[o + (int)ePut.Name13] = (byte)((Tone.Name.Length > 13) ? Tone.Name[13] : 0); Buffer[o + (int)ePut.Name14] = (byte)((Tone.Name.Length > 14) ? Tone.Name[14] : 0); Buffer[o + (int)ePut.Name15] = (byte)((Tone.Name.Length > 15) ? Tone.Name[15] : 0); } }
public static void Put(Tone @Tone, ref byte[] Buffer) { if (Tone.IsValid() && Tone.Number < ToneLength()) { int o = HeadLength() + (Tone.Number * PutLength()); int O = o + NameLength(); Put(Buffer, O, (int)ePut.AR0, 31, Tone.aOp[0].AR); Put(Buffer, O, (int)ePut.AR1, 31, Tone.aOp[1].AR); Put(Buffer, O, (int)ePut.AR2, 31, Tone.aOp[2].AR); Put(Buffer, O, (int)ePut.AR3, 31, Tone.aOp[3].AR); Put(Buffer, O, (int)ePut.DR0, 31, Tone.aOp[0].DR); Put(Buffer, O, (int)ePut.DR1, 31, Tone.aOp[1].DR); Put(Buffer, O, (int)ePut.DR2, 31, Tone.aOp[2].DR); Put(Buffer, O, (int)ePut.DR3, 31, Tone.aOp[3].DR); Put(Buffer, O, (int)ePut.SR0, 31, Tone.aOp[0].SR); Put(Buffer, O, (int)ePut.SR1, 31, Tone.aOp[1].SR); Put(Buffer, O, (int)ePut.SR2, 31, Tone.aOp[2].SR); Put(Buffer, O, (int)ePut.SR3, 31, Tone.aOp[3].SR); Put(Buffer, O, (int)ePut.RR0, 15, Tone.aOp[0].RR); Put(Buffer, O, (int)ePut.RR1, 15, Tone.aOp[1].RR); Put(Buffer, O, (int)ePut.RR2, 15, Tone.aOp[2].RR); Put(Buffer, O, (int)ePut.RR3, 15, Tone.aOp[3].RR); Put(Buffer, O, (int)ePut.SL0, 15, Tone.aOp[0].SL); Put(Buffer, O, (int)ePut.SL1, 15, Tone.aOp[1].SL); Put(Buffer, O, (int)ePut.SL2, 15, Tone.aOp[2].SL); Put(Buffer, O, (int)ePut.SL3, 15, Tone.aOp[3].SL); Put(Buffer, O, (int)ePut.TL0, 127, Tone.aOp[0].TL); Put(Buffer, O, (int)ePut.TL1, 127, Tone.aOp[1].TL); Put(Buffer, O, (int)ePut.TL2, 127, Tone.aOp[2].TL); Put(Buffer, O, (int)ePut.TL3, 127, Tone.aOp[3].TL); Put(Buffer, O, (int)ePut.KS0, 3, Tone.aOp[0].KS); Put(Buffer, O, (int)ePut.KS1, 3, Tone.aOp[1].KS); Put(Buffer, O, (int)ePut.KS2, 3, Tone.aOp[2].KS); Put(Buffer, O, (int)ePut.KS3, 3, Tone.aOp[3].KS); Put(Buffer, O, (int)ePut.ML0, 15, Tone.aOp[0].ML); Put(Buffer, O, (int)ePut.ML1, 15, Tone.aOp[1].ML); Put(Buffer, O, (int)ePut.ML2, 15, Tone.aOp[2].ML); Put(Buffer, O, (int)ePut.ML3, 15, Tone.aOp[3].ML); Put(Buffer, O, (int)ePut.DT1_0, 99, Tone.aOp[0].DT); Put(Buffer, O, (int)ePut.DT1_1, 99, Tone.aOp[1].DT); Put(Buffer, O, (int)ePut.DT1_2, 99, Tone.aOp[2].DT); Put(Buffer, O, (int)ePut.DT1_3, 99, Tone.aOp[3].DT); Put(Buffer, O, (int)ePut.DT2_0, 3, Tone.aOp[0].DT2); Put(Buffer, O, (int)ePut.DT2_1, 3, Tone.aOp[1].DT2); Put(Buffer, O, (int)ePut.DT2_2, 3, Tone.aOp[2].DT2); Put(Buffer, O, (int)ePut.DT2_3, 3, Tone.aOp[3].DT2); Put(Buffer, O, (int)ePut.AL, 7, Tone.AL); Put(Buffer, O, (int)ePut.FB, 7, Tone.FB); Put(Buffer, O, (int)ePut.MX, 7, 7); Put(Buffer, O, (int)ePut.OS, 1, 1); Put(Buffer, O, (int)ePut.PB, 127, 2); if (String.IsNullOrWhiteSpace(Tone.Name)) { Tone.Name = Tone.Number.ToString(); } Buffer[o + (int)eName.Name0] = (byte)((Tone.Name.Length > 0) ? Tone.Name[0] : 0); Buffer[o + (int)eName.Name1] = (byte)((Tone.Name.Length > 1) ? Tone.Name[1] : 0); Buffer[o + (int)eName.Name2] = (byte)((Tone.Name.Length > 2) ? Tone.Name[2] : 0); Buffer[o + (int)eName.Name3] = (byte)((Tone.Name.Length > 3) ? Tone.Name[3] : 0); Buffer[o + (int)eName.Name4] = (byte)((Tone.Name.Length > 4) ? Tone.Name[4] : 0); Buffer[o + (int)eName.Name5] = (byte)((Tone.Name.Length > 5) ? Tone.Name[5] : 0); Buffer[o + (int)eName.Name6] = (byte)((Tone.Name.Length > 6) ? Tone.Name[6] : 0); Buffer[o + (int)eName.Name7] = (byte)((Tone.Name.Length > 7) ? Tone.Name[7] : 0); Buffer[o + (int)eName.Name8] = (byte)((Tone.Name.Length > 8) ? Tone.Name[8] : 0); Buffer[o + (int)eName.Name9] = (byte)((Tone.Name.Length > 9) ? Tone.Name[9] : 0); Buffer[o + (int)eName.Name10] = (byte)((Tone.Name.Length > 10) ? Tone.Name[10] : 0); Buffer[o + (int)eName.Name11] = (byte)((Tone.Name.Length > 11) ? Tone.Name[11] : 0); Buffer[o + (int)eName.Name12] = (byte)((Tone.Name.Length > 12) ? Tone.Name[12] : 0); Buffer[o + (int)eName.Name13] = (byte)((Tone.Name.Length > 13) ? Tone.Name[13] : 0); Buffer[o + (int)eName.Name14] = (byte)((Tone.Name.Length > 14) ? Tone.Name[14] : 0); Buffer[o + (int)eName.Name15] = (byte)((Tone.Name.Length > 15) ? Tone.Name[15] : 0); Buffer[o + (int)eName.Name16] = (byte)((Tone.Name.Length > 16) ? Tone.Name[16] : 0); Buffer[o + (int)eName.Name17] = (byte)((Tone.Name.Length > 17) ? Tone.Name[17] : 0); Buffer[o + (int)eName.Name18] = (byte)((Tone.Name.Length > 18) ? Tone.Name[18] : 0); Buffer[o + (int)eName.Name19] = (byte)((Tone.Name.Length > 19) ? Tone.Name[19] : 0); Buffer[o + (int)eName.Name20] = (byte)((Tone.Name.Length > 20) ? Tone.Name[20] : 0); } }
public static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var vTone = new Tone(); int nTok = 0; var BufferMuc = ""; var BufferDat = Dat.New(); var BufferPmd = ""; var BufferVopm = Vopm.New(); var State = eState.Entry; var aLine = ReadLine(Path); foreach (var Line in aLine) { if (String.IsNullOrWhiteSpace(Line)) { continue; } if (Line[0] != '\'') { continue; } var bPartCommnet = false; var aChar = Line.ToCharArray(); var oChar = 0; foreach (var Char in aChar) { var bPart = (Char == ';'); if (bPartCommnet) { aChar[oChar] = ' '; } if (bPart) { bPartCommnet = !bPartCommnet; } if (bPartCommnet) { aChar[oChar] = ' '; } ++oChar; } var Text = new string(aChar); switch (State) { case eState.Entry: { var bHead = Text.StartsWith("'@"); if (bHead) { nTok = 9; var oSub = 0; Text = Text.Substring(2).Trim(); if (Text.StartsWith("F")) { nTok = 9; oSub = 1; } if (Text.StartsWith("FA")) { nTok = 10; oSub = 2; } if (Text.StartsWith("FC")) { nTok = 11; oSub = 2; } Text = Text.Substring(oSub); var aTok = Text.Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 1) { int.TryParse(aTok[0], out vTone.Number); State = eState.Op0; break; } } break; } case eState.Op0: { var bHead = Text.StartsWith("'@"); if (bHead) { Text = Text.Substring(2); var aTok = Text.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[0], nTok); State = eState.Op1; break; } } State = eState.Entry; break; } case eState.Op1: { var bHead = Text.StartsWith("'@"); if (bHead) { Text = Text.Substring(2); var aTok = Text.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[1], nTok); State = eState.Op2; break; } } State = eState.Entry; break; } case eState.Op2: { var bHead = Text.StartsWith("'@"); if (bHead) { Text = Text.Substring(2); var aTok = Text.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[2], nTok); State = eState.Op3; break; } } State = eState.Entry; break; } case eState.Op3: { var bHead = Text.StartsWith("'@"); if (bHead) { Text = Text.Substring(2); var aTok = Text.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[3], nTok); State = eState.Header; break; } } State = eState.Entry; break; } case eState.Header: { var bHead = Text.StartsWith("'@"); if (bHead) { Text = Text.Substring(2); var aTok = Text.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 2) { int.TryParse(aTok[0], out vTone.AL); int.TryParse(aTok[1], out vTone.FB); vTone.Name = ""; if (Option.bMuc) { Muc.Put(vTone, ref BufferMuc); } if (Option.bDat) { Dat.Put(vTone, ref BufferDat); } if (Option.bPmd) { Pmd.Put(vTone, ref BufferPmd); } if (Option.bVopm) { Vopm.Put(vTone, ref BufferVopm); } if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } } State = eState.Entry; break; } } } if (Option.bMuc) { Muc.Writer(Path, BufferMuc); } if (Option.bDat) { Dat.Writer(Path, BufferDat); } if (Option.bPmd) { Pmd.Writer(Path, BufferPmd); } if (Option.bVopm) { Vopm.Writer(Path, BufferVopm); } return(tones); }
static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var vTone = new Tone(); var Type = eType.Mucom; var nTok = 0; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferPmd = ""; var BufferVopm = Vopm.New(); var State = eState.Entry; var aLine = ReadLine(Path); foreach (var Line in aLine) { if (String.IsNullOrWhiteSpace(Line)) { continue; } if (Line[0] == '\'') { continue; } var oMark = Line.IndexOf(';'); var Text = (oMark >= 0)? Line.Remove(oMark): Line; switch (State) { case eState.Entry: { Text = Text.Trim(); var bHead = Text.StartsWith("@"); var bTail = Text.EndsWith(":{"); if (bHead) { vTone.Number++; Type = (bTail) ? eType.Mucom : eType.Mmldrv; nTok = (bTail) ? 9 : 11; var aTok = Text.Split(new char[] { ' ', '\t', '@', ':', '{', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 1) { int Number; if (int.TryParse(aTok[0], out Number)) { vTone.Number = Number; } } State = eState.Header; break; } break; } case eState.Header: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 2) { switch (Type) { case eType.Mucom: { int.TryParse(aTok[0], out vTone.FB); int.TryParse(aTok[1], out vTone.AL); break; } case eType.Mmldrv: { int.TryParse(aTok[0], out vTone.AL); int.TryParse(aTok[1], out vTone.FB); break; } } State = eState.Op0; break; } State = eState.Entry; break; } case eState.Op0: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[0], Type); State = eState.Op1; break; } State = eState.Entry; break; } case eState.Op1: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[1], Type); State = eState.Op2; break; } State = eState.Entry; break; } case eState.Op2: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[2], Type); State = eState.Op3; break; } State = eState.Entry; break; } case eState.Op3: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); switch (Type) { case eType.Mucom: { if (aTok.Length >= (nTok + 1)) { GetOp(aTok, ref vTone.aOp[3], Type); var Tok = ""; for (int o = nTok; o < aTok.Length; ++o) { Tok += aTok[o]; } var oHead = Tok.IndexOf('\"'); var oTail = Tok.IndexOf('\"', oHead + 1); var bTerm = Tok.EndsWith("}"); if (oHead >= 0 && oTail >= 0 && bTerm) { vTone.Name = Tok.Substring(oHead + 1, oTail - oHead - 1); if (Option.bDat) { Dat.Put(vTone, ref BufferDat); } if (Option.bFmp) { Fmp.Put(vTone, ref BufferFmp); } if (Option.bPmd) { Pmd.Put(vTone, ref BufferPmd); } if (Option.bVopm) { Vopm.Put(vTone, ref BufferVopm); } if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } } break; } case eType.Mmldrv: { if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[3], Type); vTone.Name = ""; if (Option.bDat) { Dat.Put(vTone, ref BufferDat); } if (Option.bFmp) { Fmp.Put(vTone, ref BufferFmp); } if (Option.bPmd) { Pmd.Put(vTone, ref BufferPmd); } if (Option.bVopm) { Vopm.Put(vTone, ref BufferVopm); } if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } break; } } State = eState.Entry; break; } } } if (Option.bDat) { Dat.Writer(Path, BufferDat); } if (Option.bFmp) { Fmp.Writer(Path, BufferFmp); } if (Option.bPmd) { Pmd.Writer(Path, BufferPmd); } if (Option.bVopm) { Vopm.Writer(Path, BufferVopm); } return(tones); }
static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var vTone = new Tone(); var Type = eType.FM; var nTok = 0; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferPmd = ""; var BufferVopm = Vopm.New(); var State = eState.Entry; var aLine = ReadLine(Path); foreach (var Line in aLine) { if (String.IsNullOrWhiteSpace(Line)) { continue; } if (Line[0] != '\'') { continue; } var oMark = Line.IndexOf(';'); var Text = (oMark >= 0) ? Line.Remove(oMark) : Line; switch (State) { case eState.Entry: { Text = Text.Trim(); var bHead = Text.StartsWith("'@ "); if (bHead) { List <string> list = new List <string>(); foreach (Match match in headerSplit.Matches(Text)) { var curr = match.Value; if (curr.Length != 0) { list.Add(curr.TrimStart(',').Trim()); } } var aTok = list.ToArray(); if (aTok.Length >= 3) { switch (aTok[1]) { case "F": Type = eType.FM; break; case "N": Type = eType.OPN; break; case "M": Type = eType.OPM; break; case "LL": Type = eType.OPLL; break; case "L": Type = eType.OPL3_2; break; case "L4": Type = eType.OPL3_4; break; } //No int Number; if (int.TryParse(aTok[2], out Number)) { vTone.Number = Number; } //Name if (aTok.Length >= 4) { vTone.Name = aTok[3].Trim('"'); } else { vTone.Name = null; } } State = eState.Header; break; } break; } case eState.Header: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[0], Type); State = eState.Op0; break; } State = eState.Entry; break; } case eState.Op0: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[1], Type); if (Type == eType.OPLL || Type == eType.OPL3_2) { State = eState.Op3; } else { State = eState.Op1; } break; } State = eState.Entry; break; } case eState.Op1: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[2], Type); State = eState.Op2; break; } State = eState.Entry; break; } case eState.Op2: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= nTok) { GetOp(aTok, ref vTone.aOp[3], Type); State = eState.Op3; break; } State = eState.Entry; break; } case eState.Op3: { var aTok = Text.Split(new char[] { ' ', '\t', ',', }, StringSplitOptions.RemoveEmptyEntries); switch (Type) { case eType.FM: case eType.OPN: case eType.OPM: { if (aTok.Length >= 3) { int.TryParse(aTok[1], out vTone.AL); int.TryParse(aTok[2], out vTone.FB); if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } break; } case eType.OPLL: { if (aTok.Length >= 3) { int.TryParse(aTok[1], out vTone.aOp[0].TL); vTone.aOp[0].TL *= 2; int.TryParse(aTok[2], out vTone.FB); if (vTone.IsValid2Op()) { tones.Add(new Tone(vTone)); } } break; } case eType.OPL3_2: { if (aTok.Length >= 3) { int.TryParse(aTok[1], out vTone.CNT); int.TryParse(aTok[2], out vTone.FB); if (vTone.IsValid2Op()) { tones.Add(new Tone(vTone)); } } break; } case eType.OPL3_4: { if (aTok.Length >= 3) { int cnt1, cnt2; int.TryParse(aTok[1], out cnt1); int.TryParse(aTok[2], out cnt2); vTone.CNT = ((cnt2 << 1) | cnt1) + 2; int.TryParse(aTok[3], out vTone.FB); if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } break; } } State = eState.Entry; break; } } } if (Option.bDat) { Dat.Writer(Path, BufferDat); } if (Option.bFmp) { Fmp.Writer(Path, BufferFmp); } if (Option.bPmd) { Pmd.Writer(Path, BufferPmd); } if (Option.bVopm) { Vopm.Writer(Path, BufferVopm); } return(tones); }
public static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var vTone = new Tone(); bool bLineComment = false; var BufferMuc = ""; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferVopm = Vopm.New(); var State = eState.Entry; var aLine = ReadLine(Path); foreach (var Line in aLine) { if (String.IsNullOrWhiteSpace(Line)) { continue; } var bLine = (Line[0] == '`'); if (bLine) { bLineComment = !bLineComment; continue; } if (bLineComment) { continue; } var bPartCommnet = false; var bTailCommnet = false; var aChar = Line.ToCharArray(); var oChar = 0; foreach (var Char in aChar) { if (bTailCommnet) { aChar[oChar] = ' '; } var bPart = (Char == '`'); if (bPartCommnet) { aChar[oChar] = ' '; } if (bPart) { bPartCommnet = !bPartCommnet; } if (bPartCommnet) { aChar[oChar] = ' '; } if (Char == ';') { bTailCommnet = true; } if (bTailCommnet) { aChar[oChar] = ' '; } ++oChar; } var Text = new string(aChar); switch (State) { case eState.Entry: { if (Text[0] == ' ' || Text[0] == '\t') { continue; } var bHead = Text.StartsWith("@"); var oName = Text.IndexOf('='); if (bHead) { var aTok = Text.Split(new char[] { ' ', '\t', '=', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 3) { aTok[0] = aTok[0].Substring(1); int.TryParse(aTok[0], out vTone.Number); int.TryParse(aTok[1], out vTone.AL); int.TryParse(aTok[2], out vTone.FB); vTone.Name = (aTok.Length >= 4 && oName > 0) ? aTok[3] : ""; State = eState.Op0; break; } } break; } case eState.Op0: { var aTok = Text.Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 10) { GetOp(aTok, ref vTone.aOp[0]); State = eState.Op1; break; } State = eState.Entry; break; } case eState.Op1: { var aTok = Text.Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 10) { GetOp(aTok, ref vTone.aOp[1]); State = eState.Op2; break; } State = eState.Entry; break; } case eState.Op2: { var aTok = Text.Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 10) { GetOp(aTok, ref vTone.aOp[2]); State = eState.Op3; break; } State = eState.Entry; break; } case eState.Op3: { var aTok = Text.Split(new char[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); if (aTok.Length >= 10) { GetOp(aTok, ref vTone.aOp[3]); if (Option.bMuc) { Muc.Put(vTone, ref BufferMuc); } if (Option.bDat) { Dat.Put(vTone, ref BufferDat); } if (Option.bFmp) { Fmp.Put(vTone, ref BufferFmp); } if (Option.bVopm) { Vopm.Put(vTone, ref BufferVopm); } if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } State = eState.Entry; break; } } } if (Option.bMuc) { Muc.Writer(Path, BufferMuc); } if (Option.bDat) { Dat.Writer(Path, BufferDat); } if (Option.bFmp) { Fmp.Writer(Path, BufferFmp); } if (Option.bVopm) { Vopm.Writer(Path, BufferVopm); } return(tones); }
public static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var Buffer = ReadByte(Path); if (Buffer.Length == DatLength()) { Tone vTone = new Tone(); var BufferMuc = ""; var BufferFmp = ""; var BufferPmd = ""; var BufferVopm = Vopm.New(); for (int i = 0; i < ToneLength(); ++i) { Get(ref vTone, Buffer, i); if (Option.bMuc) { Muc.Put(vTone, ref BufferMuc); } if (Option.bFmp) { Fmp.Put(vTone, ref BufferFmp); } if (Option.bPmd) { Pmd.Put(vTone, ref BufferPmd); } if (Option.bVopm) { Vopm.Put(vTone, ref BufferVopm); } if (vTone.IsValid() && i != 0) //skip index 0 tone is dummy { tones.Add(new Tone(vTone)); } } if (Option.bMuc) { Muc.Writer(Path, BufferMuc); } if (Option.bFmp) { Fmp.Writer(Path, BufferFmp); } if (Option.bPmd) { Pmd.Writer(Path, BufferPmd); } if (Option.bVopm) { Vopm.Writer(Path, BufferVopm); } } return(tones); }
public static IEnumerable <Tone> Reader(string Path, Option @Option) { List <Tone> tones = new List <Tone>(); var Buffer = ReadByte(Path); if (Buffer.Length == FxbLength()) { Tone vTone = new Tone(); var BufferMuc = ""; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferPmd = ""; for (int i = 0; i < ToneLength(); ++i) { Get(ref vTone, Buffer, i); if (Option.bMuc) { Muc.Put(vTone, ref BufferMuc); } if (Option.bDat) { Dat.Put(vTone, ref BufferDat); } if (Option.bFmp) { Fmp.Put(vTone, ref BufferFmp); } if (Option.bPmd) { Pmd.Put(vTone, ref BufferPmd); } if (vTone.IsValid()) { tones.Add(new Tone(vTone)); } } if (Option.bMuc) { Muc.Writer(Path, BufferMuc); } if (Option.bDat) { Dat.Writer(Path, BufferDat); } if (Option.bFmp) { Fmp.Writer(Path, BufferFmp); } if (Option.bPmd) { Pmd.Writer(Path, BufferPmd); } } return(tones); }