protected override void SetLfo(outDatum od, int ch, int cc) { string s = (string)od.args[7]; lfoSw[od.linePos.ch] = s; }
protected override void SetRest(outDatum od, int ch, int cc) { notecmd[ch] = "r"; length[ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * clockCounter[ch] / (int)od.args[0], (int)od.args[0]); }
public abstract void SetParameter(outDatum od, int cc);
public void start(byte ChipID, uint DataPos, byte LenMode, uint Length, outDatum od) { dac_control chip = DACData[ChipID]; chip.od = od; uint CmdStepBase; if ((chip.Running & 0x80) != 0) { return; } CmdStepBase = (uint)(chip.CmdSize * chip.StepBase); if (DataPos != 0xFFFFFFFF) // skip setting DataStart, if Pos == -1 { chip.DataStart = DataPos + CmdStepBase; if (chip.DataStart > chip.DataLen) // catch bad value and force silence { chip.DataStart = chip.DataLen; } } switch (LenMode & 0x0F) { case DCTRL_LMODE_IGNORE: // Length is already set - ignore break; case DCTRL_LMODE_CMDS: // Length = number of commands chip.CmdsToSend = Length; break; case DCTRL_LMODE_MSEC: // Length = time in msec chip.CmdsToSend = 1000 * Length / chip.Frequency; break; case DCTRL_LMODE_TOEND: // play unti stop-command is received (or data-end is reached) chip.CmdsToSend = (chip.DataLen - (chip.DataStart - CmdStepBase)) / chip.DataStep; break; case DCTRL_LMODE_BYTES: // raw byte count chip.CmdsToSend = Length / chip.DataStep; break; default: chip.CmdsToSend = 0x00; break; } chip.Reverse = (byte)((LenMode & 0x10) >> 4); chip.RemainCmds = chip.CmdsToSend; chip.Step = 0x00; chip.Pos = 0x00; if (chip.Reverse == 0) { chip.RealPos = 0x00; } else { chip.RealPos = (chip.CmdsToSend - 0x01) * chip.DataStep; } chip.Running &= 0xfb; // ~0x04; chip.Running |= (byte)((LenMode & 0x80) != 0 ? 0x04 : 0x00); // set loop mode chip.Running |= 0x01; // start chip.Running &= 0xef; // ~0x10; // command isn't yet sent return; }
public override void SetParameter(outDatum od, int cc) { if (isTrace) { TraceInfo[od.linePos.ch].Enqueue(od); } int n; string s; switch (od.type) { case enmMMLType.Instrument: inst[od.linePos.ch] = od.args[1].ToString(); break; case enmMMLType.Octave: octave[od.linePos.ch] = (int)od.args[0]; break; case enmMMLType.OctaveDown: octave[od.linePos.ch]--; break; case enmMMLType.OctaveUp: octave[od.linePos.ch]++; break; case enmMMLType.Note: if (od.args != null && od.args.Count > 0) { Core.Note nt = (Core.Note)od.args[0]; int shift = nt.shift; string f = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift)); notecmd[od.linePos.ch] = string.Format("o{0}{1}{2}", octave[od.linePos.ch], nt.cmd, f); length[od.linePos.ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length); if (!beforeTie[od.linePos.ch]) { if (vol[od.linePos.ch] != null) { keyOnMeter[od.linePos.ch] = (int)(256.0 / 128.0 * vol[od.linePos.ch]); } } beforeTie[od.linePos.ch] = nt.tieSw; } break; case enmMMLType.Rest: Core.Rest rs = (Core.Rest)od.args[0]; notecmd[od.linePos.ch] = "r"; length[od.linePos.ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length); break; case enmMMLType.Volume: if (od.linePos != null) { vol[od.linePos.ch] = (int)od.args[0]; } break; case enmMMLType.Pan: n = (int)od.args[0]; pan[od.linePos.ch] = n == 0 ? "-" : (n == 1 ? "Right" : (n == 2 ? "Left" : "Center")); break; case enmMMLType.Envelope: s = (string)od.args[0]; envSw[od.linePos.ch] = s == "EON" ? "ON " : "OFF"; break; case enmMMLType.LfoSwitch: s = (string)od.args[2]; lfoSw[od.linePos.ch] = s; break; case enmMMLType.Detune: n = (int)od.args[0]; detune[od.linePos.ch] = n; break; case enmMMLType.KeyShift: n = (int)od.args[0]; keyShift[od.linePos.ch] = n; break; } }
private void SendPort0(outDatum od, ref uint vgmAdr) { chipRegister.YMF262SetRegister(od, Audio.DriverSeqCounter, Index, (vgmBuf[vgmAdr].val & 0x80) == 0 ? 0 : 1, vgmBuf[vgmAdr + 1].val, vgmBuf[vgmAdr + 2].val); vgmAdr += 3; }
protected override void SetInstrument(outDatum od, int ch, int cc) { envelope[od.linePos.ch] = ((int)od.args[1]).ToString(); }
protected virtual int ShapingCh(outDatum od) { int ch = od.linePos.ch; return(ch); }
//0 - protected virtual void SetTempo(outDatum od, int ch, int cc) { }
public bool Enq(outDatum od, long Counter, Chip Chip, EnmDataType Type, int Address, int Data, object ExData) { return(ringBuffer.Enq(od, Counter, Chip, Type, Address, Data, ExData)); }
public bool Deq(ref outDatum od, ref long Counter, ref Chip Chip, ref EnmDataType Type, ref int Address, ref int Data, ref object ExData) { return(ringBuffer.Deq(ref od, ref Counter, ref Chip, ref Type, ref Address, ref Data, ref ExData)); }
private void OnDataSeqFrq(long SeqCounter) { //throw new NotImplementedException(); if (mv == null) { return; } if (mv.desVGM == null) { return; } if (mv.desVGM.dat == null) { return; } if ((Audio.sm.Mode & SendMode.MML) != SendMode.MML) { if (rtMML != null) { rtMML.OneFrameSeq(); } } if (mv.desVGM.dat.Count == 0) { return; } eChip = Audio.GetChip(EnmChip.YM2612); if (eChip == null) { return; } Enq enq = SoundManager.GetDriverDataEnqueue(); List <outDatum> dat = mv.desVGM.dat; lock (lockObject) { int badr = 0; while (badr < dat.Count) { outDatum od = dat[badr]; if (od == null) { badr++; continue; } byte val = od.val; switch (val) { case 0x52: byte adr = dat[badr + 1].val; byte prm = dat[badr + 2].val; enq(dat[badr], SeqCounter, eChip, EnmDataType.Normal, adr, prm, null); //enq(dat[badr], 0, eChip, EnmDataType.Normal, adr, prm, null); if (adr == 0x28 && dat[badr].type == enmMMLType.Note && dat[badr].args != null && dat[badr].args.Count > 1) { log.Write(string.Format("noteLog: note:{0} counter:{1}", (int)dat[badr].args[1], SeqCounter)); if (recMode != 0) { if ((int)dat[badr].args[1] >= 0) { NoteON(SeqCounter, (int)dat[badr].args[1]); } else { NoteOFF(SeqCounter, (int)dat[badr].args[1]); } } } badr += 2; break; } badr++; } dat.Clear(); } }
public override void SetParameter(outDatum od, int cc) { if (isTrace) { TraceInfo[od.linePos.ch].Enqueue(od); } switch (od.type) { case enmMMLType.Instrument: break; case enmMMLType.Octave: break; case enmMMLType.OctaveDown: break; case enmMMLType.OctaveUp: break; case enmMMLType.Note: if (od.args != null && od.args.Count > 0) { Core.Note nt = (Core.Note)od.args[0]; int shift = nt.shift; string f = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift)); notecmd[od.linePos.ch] = string.Format("o{0}{1}{2}", octave[od.linePos.ch], nt.cmd, f); length[od.linePos.ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length); if (!beforeTie[od.linePos.ch]) { if (vol[od.linePos.ch] != null) { keyOnMeter[od.linePos.ch] = (int)(256.0 / 16.0 * vol[od.linePos.ch]); } } beforeTie[od.linePos.ch] = nt.tieSw; } break; case enmMMLType.Rest: Core.Rest rs = (Core.Rest)od.args[0]; notecmd[od.linePos.ch] = "r"; length[od.linePos.ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length); break; case enmMMLType.Lyric: int ls = (int)od.args[1]; notecmd[od.linePos.ch] = "lyric"; length[od.linePos.ch] = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / ls, ls); keyOnMeter[od.linePos.ch] = (int)(255.0); break; case enmMMLType.Volume: break; case enmMMLType.Pan: break; case enmMMLType.Envelope: break; case enmMMLType.LfoSwitch: break; case enmMMLType.Detune: break; case enmMMLType.KeyShift: break; } }
private void SendPort0(outDatum od, ref uint vgmAdr) { chipRegister.SEGAPCMSetRegister(od, Audio.DriverSeqCounter, Index, (int)((vgmBuf[vgmAdr + 0x01].val & 0xFF) | ((vgmBuf[vgmAdr + 0x02].val & 0xFF) << 8)), vgmBuf[vgmAdr + 0x03].val); vgmAdr += 4; }
private void chip_reg_write(long Counter, byte ChipType, byte ChipID, byte Port, byte Offset, byte Data, outDatum od) { switch (ChipType) { case 0x00: // SN76489 chipRegister.SN76489SetRegister(od, Counter, ChipID, Data); break; case 0x02: // YM2612 chipRegister.YM2612SetRegister(od, Counter, ChipID, Port, Offset, Data); //log.Write(string.Format("Cnt{0} Data{1}",Counter,Data)); break; case 0x06: // YM2203+ chipRegister.YM2203SetRegister(od, Counter, ChipID, Offset, Data); break; case 0x07: // YM2608+ chipRegister.YM2608SetRegister(od, Counter, ChipID, Port, Offset, Data); break; case 0x08: // YM2610+ chipRegister.YM2610SetRegister(od, Counter, ChipID, Port, Offset, Data); break; case 0x10: chipRegister.RF5C164SetRegister(od, Counter, ChipID, Offset, Data); break; case 0x11: // PWM chipRegister.writePWM(ChipID, Port, (uint)((Offset << 8) | (Data << 0))); break; case 0x17: // OKIM6258 if (model == EnmVRModel.VirtualModel) //System.Console.Write("[DAC]"); { chipRegister.writeOKIM6258(ChipID, Offset, Data); } break; case 0x1b: // HuC6280 chipRegister.HuC6280SetRegister(od, Counter, ChipID, Offset, Data); break; } }
protected virtual void SetGatetime(outDatum od, int ch, int cc) { }
protected override void SetPan(outDatum od, int ch, int cc) { pan[od.linePos.ch] = string.Format("{0}", (int)od.args[0]); }
protected virtual void SetExtendChannel(outDatum od, int ch, int cc) { }
private void SendPort0(outDatum od, ref uint vgmAdr) { vgmAdr += 3; }
//40 - protected virtual void SetLyric(outDatum od, int ch, int cc) { }
private void oneFrameXGM() { while (true) { outDatum cmd = vgmBuf[musicPtr++].Copy(); //wait if (cmd.val == 0) { if (jumpPointClock < 0) { break; } jumpPointClock--;//= (long)musicStep; } //loop command if (cmd.val == 0x7e) { musicPtr = musicDataBlockAddr + Common.getLE24(vgmBuf, musicPtr); vgmCurLoop++; continue; } //end command if (cmd.val == 0x7f) { Stopped = true; break; } //TODO: Dummy Command if (cmd.val == 0x60 && Core.Common.CheckDummyCommand(cmd.type)) { chipRegister.YM2612SetRegister(cmd, Audio.DriverSeqCounter, 0, 0, -1, -1); musicPtr += 2; continue; } byte L = (byte)(cmd.val & 0xf); byte H = (byte)(cmd.val & 0xf0); if (H == 0x10) { //PSG register write: WritePSG(cmd, L); } else if (H == 0x20) { //Console.WriteLine("cmd{0:x2}", cmd.val); //YM2612 port 0 register write: WriteYM2612P0(cmd, L); } else if (H == 0x30) { //YM2612 port 1 register write: WriteYM2612P1(cmd, L); } else if (H == 0x40) { //YM2612 key off/on ($28) command write: WriteYM2612Key(cmd, L); } else if (H == 0x50) { //PCM play command: PlayPCM(cmd, L); } //else if (H == 0x60) //{ // musicPtr += 2; //} } }
//60 - protected virtual void SetTraceUpdateStack(outDatum od, int ch, int cc) { }
private void chip_reg_write(long Counter, byte ChipType, byte ChipID, byte Port, byte Offset, byte Data, outDatum od) { switch (ChipType) { case 0x00: // SN76489 chipRegister.SN76489SetRegister(od, Counter, ChipID, Data); break; case 0x01: // YM2413+ //chipRegister.setYM2413Register(ChipID, Offset, Data, model); break; case 0x02: // YM2612 chipRegister.YM2612SetRegister(od, Counter, ChipID, Port, Offset, Data); //log.Write(string.Format("Cnt{0} Data{1}",Counter,Data)); break; case 0x03: // YM2151+ //chipRegister.setYM2151Register(ChipID, Port, Offset, Data, model, 0, 0); break; case 0x06: // YM2203+ chipRegister.YM2203SetRegister(od, Counter, ChipID, Offset, Data); break; case 0x07: // YM2608+ chipRegister.YM2608SetRegister(od, Counter, ChipID, Port, Offset, Data); break; case 0x08: // YM2610+ chipRegister.YM2610SetRegister(od, Counter, ChipID, Port, Offset, Data); break; case 0x09: // YM3812+ //chipRegister.setYM3812Register(ChipID, Offset, Data, model); break; case 0x0A: // YM3526+ //chipRegister.setYM3526Register(ChipID, Offset, Data, model); break; case 0x0B: // Y8950+ //chipRegister.setY8950Register(ChipID, Offset, Data, model); break; case 0x0C: // YMF262+ //chipRegister.setYMF262Register(ChipID, Port, Offset, Data, model); break; case 0x0D: // YMF278B+ //chipRegister.setYMF278BRegister(ChipID, Port, Offset, Data, model); break; case 0x0E: // YMF271+ //chipRegister.setYMF271Register(ChipID, Port, Offset, Data, model); break; case 0x0F: // YMZ280B+ //chipRegister.setYMZ280BRegister(ChipID, Offset, Data, model); break; case 0x10: chipRegister.RF5C164SetRegister(od, Counter, ChipID, Offset, Data); break; case 0x11: // PWM chipRegister.writePWM(ChipID, Port, (uint)((Offset << 8) | (Data << 0))); break; case 0x12: // AY8910+ //chipRegister.setAY8910Register(ChipID, Offset, Data, model); break; case 0x13: // DMG+ //chipRegister.setDMGRegister(ChipID, Offset, Data, model); break; case 0x14: // NES+ //chipRegister.setNESRegister(ChipID, Offset, Data, model); break; case 0x17: // OKIM6258 if (model == EnmVRModel.VirtualModel) //System.Console.Write("[DAC]"); { chipRegister.writeOKIM6258(ChipID, Offset, Data); } break; case 0x1b: // HuC6280 chipRegister.HuC6280SetRegister(od, Counter, ChipID, Offset, Data); break; } }
protected override void SetPan(outDatum od, int ch, int cc) { int n = (int)od.args[0]; pan[od.linePos.ch] = n == 0 ? "-" : (n == 1 ? "Right" : (n == 2 ? "Left" : "Center")); }
private void SendPort0(outDatum od, ref uint vgmAdr) { chipRegister.YM2203SetRegister(od, Audio.DriverSeqCounter, Index, vgmBuf[vgmAdr + 1].val, vgmBuf[vgmAdr + 2].val); vgmAdr += 3; }
protected override void SetPan(outDatum od, int ch, int cc) { pan[od.linePos.ch] = od.args[0].ToString(); }
protected override void SetGatetime(outDatum od, int ch, int cc) { gatetime[ch] = string.Format("{0}", (int)od.args[0]); //base.SetGatetime(od, ch, cc); }
private void OnDataSeqFrq(long SeqCounter) { if (mv == null) { return; } if (mv.desVGM == null) { return; } //if ((Audio.sm.Mode & SendMode.MML) != SendMode.MML) //{ // if (rtMML != null) // rtMML.OneFrameSeq(); //} //入力時に生じた、各チップ向けの送信データをコンパイラを使用して生成する。 if (qMML.Count < 1) { return; } //生成したデータを取得 mv.desVGM.dat.Clear(); //音源への送信データキューへ追加 Enq enq = SoundManager.GetDriverDataEnqueue(); while (qMML.Count > 0) { KBDInfo kbdInfo = qMML.Dequeue(); switch (kbdInfo.mml.type) { case enmMMLType.Octave: kbdInfo.chip.CmdOctave(kbdInfo.pw.apg, kbdInfo.mml); break; case enmMMLType.Note: kbdInfo.chip.SetKeyOff(kbdInfo.pw.apg, kbdInfo.mml); if ((int)kbdInfo.mml.args[1] >= 0) { kbdInfo.chip.CmdNote(kbdInfo.pw, kbdInfo.pw.apg, kbdInfo.mml); //TODO:page制御やってない kbdInfo.chip.MultiChannelCommand(kbdInfo.mml); } break; } List <outDatum> dat = kbdInfo.pw.apg.sendData; while (0 < dat.Count) { outDatum od = dat[0]; if (od == null) { dat.RemoveAt(0); continue; } byte val = od.val; byte adr; byte prm; switch (val) { case 0x52: //OPN2 adr = dat[1].val; prm = dat[2].val; enq(dat[0], SeqCounter, kbdInfo.eChip, EnmDataType.Force, adr, prm, null); dat.RemoveAt(0); dat.RemoveAt(0); dat.RemoveAt(0); break; case 0x56: //OPNA adr = dat[1].val; prm = dat[2].val; enq(dat[0], 0, kbdInfo.eChip, EnmDataType.Force, adr, prm, null); dat.RemoveAt(0); dat.RemoveAt(0); dat.RemoveAt(0); break; case 0x57: //OPNA adr = dat[1].val; prm = dat[2].val; enq(dat[0], 0, kbdInfo.eChip, EnmDataType.Force, adr | 0x100, prm, null); dat.RemoveAt(0); dat.RemoveAt(0); dat.RemoveAt(0); break; default: dat.RemoveAt(0); break; } } } }