public static void Reader(string Path, Option @Option) { var Buffer = ReadByte(Path); if (Buffer.Length == FxbLength() && IsValid(Buffer)) { Tone vTone = new Tone(); var BufferMuc = ""; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferPmd = ""; var BufferFMtrial = FMtrial.New(); 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 (Option.bFMtrial) { FMtrial.Put(vTone, ref BufferFMtrial); } } 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); } if (Option.bFMtrial) { FMtrial.Writer(Path, BufferFMtrial); } } }
public static void Reader(string Path, Option @Option) { var vTone = new Tone(); bool bLineComment = false; var BufferMuc = ""; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferVopm = Vopm.New(); var BufferFMtrial = FMtrial.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); if (String.IsNullOrEmpty(Text.Trim(' '))) { continue; } 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 (Option.bFMtrial) { FMtrial.Put(vTone, ref BufferFMtrial); } } 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); } if (Option.bFMtrial) { FMtrial.Writer(Path, BufferFMtrial); } }
static void Reader(string Path, Option @Option) { var vTone = new Tone(); var Type = eType.Mucom; var nTok = 0; var BufferDat = Dat.New(); var BufferFmp = ""; var BufferPmd = ""; var BufferVopm = Vopm.New(); var BufferFMtrial = FMtrial.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 (Option.bFMtrial) { FMtrial.Put(vTone, ref BufferFMtrial); } } } 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 (Option.bFMtrial) { FMtrial.Put(vTone, ref BufferFMtrial); } } 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); } if (Option.bFMtrial) { FMtrial.Writer(Path, BufferFMtrial); } }
static int Main(string[] aArg) { var Option = new Option(); int oArg = 0; foreach (var Arg in aArg) { if (Arg[0] == '-') { switch (Arg) { case "-muc": { Option.bMuc = true; break; } case "-dat": { Option.bDat = true; break; } case "-fmp": { Option.bFmp = true; break; } case "-pmd": { Option.bPmd = true; break; } case "-vopm": { Option.bVopm = true; break; } case "-fmtrial": { Option.bFMtrial = true; break; } } aArg[oArg] = String.Empty; } ++oArg; } Muc.Reader(aArg, Option); Dat.Reader(aArg, Option); Fmp.Reader(aArg, Option); Pmd.Reader(aArg, Option); Vopm.Reader(aArg, Option); FMtrial.Reader(aArg, Option); return(0); }
public static void Reader(string Path, Option @Option) { var vTone = new Tone(); int nTok = 0; var BufferMuc = ""; var BufferDat = Dat.New(); var BufferPmd = ""; var BufferVopm = Vopm.New(); var BufferFMtrial = FMtrial.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); if (String.IsNullOrEmpty(Text.Trim(' '))) { continue; } 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 (Option.bFMtrial) { FMtrial.Put(vTone, ref BufferFMtrial); } } } 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); } if (Option.bFMtrial) { FMtrial.Writer(Path, BufferFMtrial); } }