static int Main(string[] args) { Log.writeLine += WriteLine; #if DEBUG //Log.writeLine += WriteLineF; Log.level = LogLevel.INFO;//.TRACE; #else Log.level = LogLevel.INFO; #endif int fnIndex = AnalyzeOption(args); if (args == null || args.Length != fnIndex + 1) { Log.WriteLine(LogLevel.ERROR, "引数(.mubファイル)1個欲しいよぉ"); return(-1); } if (!File.Exists(args[fnIndex])) { Log.WriteLine(LogLevel.ERROR, "ファイルが見つかりません"); return(-1); } try { vw = new VgmWriter(); vw.Open( Path.Combine( Path.GetDirectoryName(args[fnIndex]) , Path.GetFileNameWithoutExtension(args[fnIndex]) + ".vgm") ); #if NETCOREAPP System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); #endif List <ChipAction> lca = new List <ChipAction>(); mucomChipAction ca; ca = new mucomChipAction(OPNAWriteP, null, OPNAWaitSend); lca.Add(ca); ca = new mucomChipAction(OPNAWriteS, null, null); lca.Add(ca); ca = new mucomChipAction(OPNBWriteP, OPNBWriteAdpcmP, null); lca.Add(ca); ca = new mucomChipAction(OPNBWriteS, OPNBWriteAdpcmS, null); lca.Add(ca); List <MmlDatum> bl = new List <MmlDatum>(); byte[] srcBuf = File.ReadAllBytes(args[fnIndex]); foreach (byte b in srcBuf) { bl.Add(new MmlDatum(b)); } drv = new Driver(); ((Driver)drv).Init( lca , bl.ToArray() , null , new object[] { false , false , false } ); drv.SetLoopCount(loop); tags = ((Driver)drv).GetTags(); if (tags != null) { foreach (Tuple <string, string> tag in tags) { if (tag.Item1 == "") { continue; } Log.WriteLine(LogLevel.INFO, string.Format("{0,-16} : {1}", tag.Item1, tag.Item2)); } } byte[] pcmdata = drv.GetPCMFromSrcBuf(); if (pcmdata != null && pcmdata.Length > 0) { vw.WriteAdpcm(pcmdata); } drv.StartRendering((int)SamplingRate, new Tuple <string, int>[] { new Tuple <string, int>("YM2608", (int)opnaMasterClock) } ); drv.MusicSTART(0); while (true) { drv.Rendering(); vw.IncrementWaitCOunter(); //ステータスが0(終了)又は0未満(エラー)の場合はループを抜けて終了 if (drv.GetStatus() <= 0) { break; } } drv.MusicSTOP(); drv.StopRendering(); } catch { } finally { if (vw != null) { vw.Close(tags); } } return(0); }