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 VGMWaitTotal(VGMRead reader) { Console.WriteLine("VGMWait total"); var waits = reader.VGMCommands.Where(x => x is VGMwait).Cast <VGMwait>().ToList(); var waittotal = waits.Sum(x => x.waitsamples); Console.WriteLine("Sum:" + waittotal); Console.WriteLine("Header:" + reader.Header.Totalsamples); Console.WriteLine("Sum in msec: " + VGMWait2mSec(waittotal).ToString("N3")); }
public static void VGLCommandStatistics(VGMRead reader) { Console.WriteLine("VGL Command statistics"); var commandstat = reader.VGMCommands.GroupBy(x => x.CommandByte).Select(group => new { Command = group.Key, Count = group.Count() }).OrderBy(x => x.Command).ToList(); foreach (var item in commandstat) { Console.WriteLine(item.Command.ToString("X") + " " + item.Count); } }
public static void VGMWaitUsageStatistics(VGMRead reader) { Console.WriteLine("VGMWait usage statistics"); var waits = reader.VGMCommands.Where(x => x is VGMwait).Cast <VGMwait>().ToList(); var e2 = waits.GroupBy(x => x.waitsamples).Select(group => new { Waitsamples = group.Key, Count = group.Count() }).OrderBy(x => x.Waitsamples).ToList();; foreach (var item in e2) { Console.WriteLine(item.Waitsamples + " " + VGMWait2mSec(item.Waitsamples).ToString("N3") + " " + item.Count); } }
public static void YM3812registerUsageStatistics(VGMRead reader) { Console.WriteLine("YM3812 register usage statistics"); var oplregwrites = reader.VGMCommands.Where(x => x is YM3812Command).Cast <YM3812Command>().ToList(); var e = oplregwrites.GroupBy(x => x.Register).Select(group => new { Register = group.Key, Count = group.Count() }).OrderBy(x => x.Register).ToList(); foreach (var item in e) { Console.WriteLine(item.Register.ToString("X") + " " + item.Count); } }
public static void YM3812WaveformStatistics(VGMRead reader) { //E0-F5 Wave select Console.WriteLine("YM3812 Waveform statistics"); var oplregwrites = reader.VGMCommands.Where(x => x is YM3812Command).Cast <YM3812Command>().ToList(); oplregwrites = oplregwrites.Where(x => x.Register >= 0xE0 && x.Register <= 0xF5).ToList(); var waves = oplregwrites.GroupBy(x => x.Value).Select(group => new { Wave = group.Key, Count = group.Count() }).OrderBy(x => x.Wave).ToList(); foreach (var item in waves) { Console.WriteLine(item.Wave.ToString("X") + " " + item.Count); } }
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); }