public static void YM3812Notes(VGMRead reader) { Console.WriteLine("YM3812 Notes"); YM3812 chip = new YM3812(); foreach (var command in reader.VGMCommands) { if (command is YM3812Command) { chip.ConsumeCommand((YM3812Command)command); } if (command is VGMwait || command is VGMendofsounddata) { string line = "| "; for (int i = 0; i < 8; i++) { line += (chip.KeyOn(i) ? "O" : " ") + " " + Tools.FrequencyToNote(chip.Freq(i)) + " " + ((int)Math.Round(chip.Freq(i))).ToString("D4") + " | "; } if (command is VGMwait) { line += Statistics.VGMWait2mSec(((VGMwait)command).waitsamples).ToString("0000"); } Console.WriteLine(line); } } }
public static void ChannelStats(VGMRead reader) { Console.CursorVisible = false; Console.SetWindowSize(200, 50); //Console.SetWindowSize(20, 20); //Console.SetWindowPosition(100, 20); Console.SetCursorPosition(0, 0); Console.WriteLine("ChannelStats"); DrawStatic(); YM3812 chip = new YM3812(); int position = 0; foreach (var command in reader.VGMCommands) { if (command is YM3812Command) { chip.ConsumeCommand((YM3812Command)command); } if (command is VGMwait || command is VGMendofsounddata) { for (int i = 0; i < 9; i++) { var channelstat = chip.GetChannelStats(i); DrawChannelStat(channelstat); } Console.SetCursorPosition(20, 0); Console.WriteLine(position); Console.SetCursorPosition(0, 25); if (command is VGMwait) { int w = (int)(((VGMwait)command).waitsamples / 44.100); position += w; Thread.Sleep(w); } } } Console.CursorVisible = true; }
static void Main(string[] args) { //VGMRead reader = new VGMRead(@"C:\Users\mpathy\Desktop\TrackerMuzax\vgzs\03 Water.vgm"); VGMRead reader = new VGMRead(@"C:\Users\mpathy\Desktop\TrackerMuzax\vgzs\06 Chani's Eyes.vgm"); //VGMRead reader = new VGMRead(@"C:\Users\mpathy\Desktop\TrackerMuzax\vgzs\07 Sign of the Worm.vgm"); reader.Open(); //Statistics.VGMWaitTotal(reader); //Statistics.YM3812WaveformStatistics(reader); //Statistics.YM3812Notes(reader); //Visulaize.ChannelStats(reader); double waittickcorrection = 0; double x16tickinmillisec = 1000 / 60; YM3812 ym3812 = new YM3812(); YM2151 ym2151 = new YM2151(); List <byte> outbytes = new List <byte>(); //Start pause. //outbytes.AddRange(new byte[] { 0, 60 }); ym2151.Reset(); ym2151.NextTick(); ym3812.NextTick(); foreach (var command in reader.VGMCommands) { if (command is YM3812Command) { ym3812.ConsumeCommand((YM3812Command)command); } if (command is VGMwait || command is VGMendofsounddata) { ConvertYM3812stateToYM2151state(ym3812, ym2151); outbytes.AddRange(ym2151.GetChangedRegisters()); outbytes.AddRange(ConvertYM3812KeyOnStateToYM2151KeyOnCommands(ym3812)); if (command is VGMwait) { var waitmillisecs = ((VGMwait)command).waitsamples / 44.100; var unroundedwaitticks = waitmillisecs / x16tickinmillisec; unroundedwaitticks += waittickcorrection; var waitticks = Math.Round(unroundedwaitticks); waittickcorrection = unroundedwaitticks - waitticks; if (waitticks != 0) { while (waitticks > 0) { outbytes.Add(0); if (waitticks > 255) { outbytes.Add(255); } else { outbytes.Add((byte)waitticks); } waitticks -= 255; } } } ym2151.NextTick(); ym3812.NextTick(); } } //Trailing pause //outbytes.AddRange(new byte[] { 0, 60 }); Directory.SetCurrentDirectory(@"C:\Users\mpathy\Source\Repos\TrackConv\Player"); CX16BasicWriter.ToFile(outbytes); DumbBinWriter.ToFile(outbytes); VGMWriter.ToFile(outbytes); }