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; }
public static void ConvertYM3812stateToYM2151state(YM3812 ym3812, YM2151 ym2151) { for (int channel = 0; channel < 9; channel++) { //int channel = 0; //var chs = ym3812.GetChannelStats(4); var chs = ym3812.GetChannelStats(channel); if (channel <= 7) { //Operator settings { int opnum = 0; TrackConv.YM2151operator op0 = new TrackConv.YM2151operator(); LoadFromYM3812Operator(op0, chs.OPR1); int slot = opnum * 8 + channel; SetYM2151Operator(ym2151, slot, op0); opnum = 2; TrackConv.YM2151operator op2 = new TrackConv.YM2151operator(); LoadFromYM3812Operator(op2, chs.OPR2); slot = opnum * 8 + channel; SetYM2151Operator(ym2151, slot, op2); } //PMS and AMS { byte PMS = chs.OPR2.Vibrato ? (byte)0x04 : (byte)0x00; byte AMS = chs.OPR2.AmpMod ? (byte)0x02 : (byte)0x00; //$38-$3F -PPP--AA Channel 0-7 PMS / AMS P = PMS , A = AMS byte register = (byte)(0x38 + channel); byte value = 0; value += (byte)(PMS << 4); value += AMS; ym2151.registers[register] = value; } //Connection and feedback { byte CON = 7; if (chs.Connection == 0) { CON = 6; } byte FB = (byte)chs.Feedback; //$20-$27 LRFFFCCC Channel 0-7 L = Left, R = Right, F = Feedback, C = Connection byte register = (byte)(0x20 + channel); byte value = 0b11000000; value += (byte)(FB << 3); value += CON; ym2151.registers[register] = value; } //Note (note octave cent) { var note = Tools.FrequencyToNote(chs.Freq); if (!note.OutOfRange) { int note_ = note.note; int octave_ = note.octave; int cent_ = note.cent; if (note.cent_sign < 0) { note_ -= 1; if (note_ < 0) { note_ = 11; octave_ -= 1; if (octave_ < 0) { note_ = 0; octave_ = 0; cent_ = -100; } } cent_ = 100 + cent_; } cent_ = cent_ * 64 / 100; //$28 -$2F -OOONNNN Chn0 - 7 KeyCode O = Octive, N = Note byte register = (byte)(0x28 + channel); byte value = 0; value += (byte)((note_ & 0b00000111) << 4); value += (byte)(octave_ & 0b00001111); ym2151.registers[register] = value; //$30 -$38 FFFFFF-- Chn0 - 7 F = keyFraction register = (byte)(0x30 + channel); value = 0; value += (byte)((cent_ & 0b00111111) << 2); ym2151.registers[register] = value; } } } } }