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; } } 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); return(0); }
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); } }
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); }
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); }