Skip to content

Commit

Permalink
STBL481 2024/11/09
Browse files Browse the repository at this point in the history
  PianoRoll:Driver:NRTDRV,MXDRV,MNDRV,FMP,PMD,S98追加
  PianoRoll:長く発生し続ける音があった時ノートが消えるバグを修正
  • Loading branch information
kumatan committed Nov 9, 2024
1 parent 90a0e94 commit 5c11a9c
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
�X�V����
STBL481 2024/11/09
PianoRoll:Driver:NRTDRV,MXDRV,MNDRV,FMP,PMD,S98�lj�
PianoRoll:���������������鉹�����������m�[�g��������o�O���C��

STBL480 2024/11/08 3rd
Driver:AY:�t���[���J�E���^�[�̃J�E���g�A�b�v���ł��Ă��Ȃ�����
PianoRoll:Driver:AY�lj�
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayer_InstKit/02info.nsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!define NAME "MDPlayer"
!define VERSION "STBL479"
!define VERSION "STBL480"
!define PUBLISHER "Kumata"
!define PACKAGE "${NAME} ${VERSION}"
119 changes: 119 additions & 0 deletions MDPlayer/MDPlayerx64/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,15 @@ public static bool Play(Setting setting)
};
((Driver.PMDDotNET)DriverReal).PlayingFileName = PlayingFileName;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.PMDDotNET(PMDDotNETim)
{
setting = setting
};
((Driver.PMDDotNET)DriverPianoRoll).PlayingFileName = PlayingFileName;
}
return MmlPlay_PMDDotNET(setting, PlayingFileFormat == EnmFileFormat.MML ? 0 : 1);
}

Expand Down Expand Up @@ -2261,6 +2270,16 @@ public static bool Play(Setting setting)
((Driver.FMP.FMP)DriverReal).PlayingFileName = PlayingFileName;
((Driver.FMP.FMP)DriverReal).PlayingArcFileName = PlayingArcFileName;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.FMP.FMP(ft)
{
setting = setting
};
((Driver.FMP.FMP)DriverPianoRoll).PlayingFileName = PlayingFileName;
((Driver.FMP.FMP)DriverPianoRoll).PlayingArcFileName = PlayingArcFileName;
}
return OxiPlay_FMP(setting, ft);
}

Expand Down Expand Up @@ -2309,6 +2328,14 @@ public static bool Play(Setting setting)
setting = setting
};
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new NRTDRV(setting)
{
setting = setting
};
}
return NrdPlay(setting);
}

Expand Down Expand Up @@ -2380,6 +2407,15 @@ public static bool Play(Setting setting)
};
((Driver.MXDRV.MXDRV)DriverReal).ExtendFile = (ExtendFile != null && ExtendFile.Count > 0) ? ExtendFile[0] : null;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.MXDRV.MXDRV
{
setting = setting
};
((Driver.MXDRV.MXDRV)DriverPianoRoll).ExtendFile = (ExtendFile != null && ExtendFile.Count > 0) ? ExtendFile[0] : null;
}
return MdxPlay(setting);
}

Expand All @@ -2400,6 +2436,15 @@ public static bool Play(Setting setting)
};
((Driver.MNDRV.mndrv)DriverReal).ExtendFile = ExtendFile;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.MNDRV.mndrv
{
setting = setting
};
((Driver.MNDRV.mndrv)DriverPianoRoll).ExtendFile = ExtendFile;
}
return MndPlay(setting);
}

Expand Down Expand Up @@ -2487,6 +2532,14 @@ public static bool Play(Setting setting)
setting = setting
};
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new S98(setting)
{
setting = setting
};
}

return S98Play(setting);
}
Expand Down Expand Up @@ -3654,6 +3707,12 @@ public static bool MmlPlay_PMDDotNET(Setting setting, int fileType)
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}
if (DriverPianoRoll != null)
{
if (!DriverPianoRoll.init(vgmBuf, fileType, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.YM2608 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}

//Play

Expand Down Expand Up @@ -3782,6 +3841,10 @@ public static bool OxiPlay_FMP(Setting setting,fileTemp ft)
{
((Driver.FMP.FMP)DriverReal).SetSearchPath(setting.FileSearchPathList);
}
if (DriverPianoRoll != null)
{
((Driver.FMP.FMP)DriverPianoRoll).SetSearchPath(setting.FileSearchPathList);
}

if (!DriverVirtual.init(vgmBuf, chipRegister, EnmModel.VirtualModel, new EnmChip[] { EnmChip.YM2608 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencyEmulation / 1000)
Expand All @@ -3792,6 +3855,12 @@ public static bool OxiPlay_FMP(Setting setting,fileTemp ft)
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}
if (DriverPianoRoll != null)
{
if (!DriverPianoRoll.init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.YM2608 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}

//Play

Expand Down Expand Up @@ -4641,6 +4710,13 @@ public static bool NrdPlay(Setting setting)
((NRTDRV)DriverReal).Call(0);//
}

if (DriverPianoRoll != null)
{
DriverPianoRoll.init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.YM2151, EnmChip.AY8910 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000));
((NRTDRV)DriverPianoRoll).Call(0);//
}

Paused = false;
oneTimeReset = false;
Expand All @@ -4654,6 +4730,10 @@ public static bool NrdPlay(Setting setting)
((NRTDRV)DriverReal).Call(1);//MPLAY
}

if (DriverPianoRoll != null)
{
((NRTDRV)DriverPianoRoll).Call(1);//MPLAY
}


return true;
Expand Down Expand Up @@ -4767,6 +4847,7 @@ public static bool MdxPlay(Setting setting)

MDSound.ym2151_x68sound mdxPCM_V=null;
MDSound.ym2151_x68sound mdxPCM_R = null;
MDSound.ym2151_x68sound mdxPCM_P = null;
MDSound.PCM8PP pcm8pp = null;
mdxPCM_V = new();
mdxPCM_V.x68sound[0] = new MDSound.NX68Sound.X68Sound();
Expand All @@ -4789,6 +4870,9 @@ public static bool MdxPlay(Setting setting)
mdxPCM_R = new();
mdxPCM_R.x68sound[0] = new MDSound.NX68Sound.X68Sound();
mdxPCM_R.sound_Iocs[0] = new MDSound.NX68Sound.sound_iocs(mdxPCM_R.x68sound[0]);
mdxPCM_P = new();
mdxPCM_P.x68sound[0] = new MDSound.NX68Sound.X68Sound();
mdxPCM_P.sound_Iocs[0] = new MDSound.NX68Sound.sound_iocs(mdxPCM_P.x68sound[0]);
UseChip.Add(EnmChip.PCM8);
((Driver.MXDRV.MXDRV)DriverVirtual).pcm8type = 0;
if (setting.mxdrv.pcm8type == 0)
Expand Down Expand Up @@ -4862,6 +4946,13 @@ public static bool MdxPlay(Setting setting)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000)
, mdxPCM_R, null);
}
if (DriverPianoRoll != null)
{
((MDPlayer.Driver.MXDRV.MXDRV)DriverPianoRoll).Init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.Unuse }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000)
, mdxPCM_P, null);
}

if (!retV || !retR)
{
Expand Down Expand Up @@ -5168,6 +5259,13 @@ public static bool MndPlay(Setting setting)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000)
);
}
if (DriverPianoRoll != null)
{
((MDPlayer.Driver.MNDRV.mndrv)DriverPianoRoll).init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.YM2151, EnmChip.YM2608 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000)
);
}

if (!retV || !retR)
{
Expand Down Expand Up @@ -5766,6 +5864,12 @@ public static bool S98Play(Setting setting)
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}
if (DriverPianoRoll != null)
{
if (!DriverPianoRoll.init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.YM2203 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}

List<S98.S98DevInfo> s98DInfo = ((S98)DriverVirtual).s98Info.DeviceInfos;

Expand Down Expand Up @@ -9207,6 +9311,20 @@ public static long GetDriverCounter()
return 0;
}

public static long GetVgmFrameCounter()
{
if (DriverVirtual == null && DriverReal == null) return -1;

if (DriverVirtual == null)
return DriverReal.vgmFrameCounter;
if (DriverReal == null)
return DriverVirtual.vgmFrameCounter;

long vVFC = DriverVirtual.vgmFrameCounter;
long vRFC = DriverReal.vgmFrameCounter;
return vVFC > vRFC ? vVFC : vRFC;
}

public static long GetLoopCounter()
{
if (DriverVirtual == null) return -1;
Expand Down Expand Up @@ -9726,6 +9844,7 @@ private static int TrdVgmVirtualMainFunction(short[] buffer, int offset, int sam
cnt = (Int32)mXDRV.Render(buffer, offset + i, 2);

mds.Update(buffer, offset + i, 2, null);
if (DriverPianoRoll != null) DriverPianoRoll.oneFrameProc();
}
//cnt = (Int32)((Driver.MXDRV.MXDRV)driverVirtual).Render(buffer, offset , sampleCount);
//mds.Update(buffer, offset , sampleCount, null);
Expand Down
6 changes: 5 additions & 1 deletion MDPlayer/MDPlayerx64/Driver/FMP/FMP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ public override void oneFrameProc()
Counter++;

nise98.Runtimer();
if (!nise98.IntTimer()) continue;
if (!nise98.IntTimer())
{
vgmFrameCounter++;
continue;
}
regs.SS = unchecked((short)0xE000);
regs.SP = 0x0000;
nise98.CallRunfunctionCall(0x14);
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/MNDRV/mndrv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,7 @@ public void _OPM_WRITE()
//while ((sbyte)mm.ReadByte(reg.a0) < 0) ; //wait?
//mm.Write(reg.a0, (byte)reg.D0_B);
//log.Write(string.Format("adr:{0:x} dat:{1:x}", reg.a0, reg.D0_B));
chipRegister.setYM2151Register(0, 0, (int)reg.D1_B, (int)reg.D0_B, model, YM2151Hosei[0], 0);
chipRegister.setYM2151Register(0, 0, (int)reg.D1_B, (int)reg.D0_B, model, YM2151Hosei[0], vgmFrameCounter);
timerOPM.WriteReg((byte)reg.D1_B, (byte)reg.D0_B);
}

Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/MXDRV/MXDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ private void OPM_SUB()
//Debug.WriteLine("{0:x02} {1:x02}", D1 & 0xff, D2 & 0xff);

mdxPCM?.sound_Iocs[0]._iocs_opmset((byte)D1, (byte)D2);
chipRegister.setYM2151Register(0, 0, (int)D1, (int)D2, model, YM2151Hosei[0], 0);
chipRegister.setYM2151Register(0, 0, (int)D1, (int)D2, model, YM2151Hosei[0], vgmFrameCounter);

if (D1 == 0x10)
{
Expand Down
19 changes: 8 additions & 11 deletions MDPlayer/MDPlayerx64/Driver/NRTDRV/NRTDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,22 +880,22 @@ private void lreset()

private void wopm(byte d, byte a)
{
if (model == EnmModel.VirtualModel)
if (model == EnmModel.VirtualModel || model == EnmModel.PianoRollModel)
{
if (work.OPMIO == 0x701)
{
//仮想レジスタに書き込み
work.OPM1vreg[d] = a;
//実レジスタに書き込み
chipRegister.setYM2151Register(0, 0, d, a, EnmModel.VirtualModel, 0, 0);
chipRegister.setYM2151Register(0, 0, d, a, model, 0, vgmFrameCounter);
//Console.WriteLine($"OPM1 Reg{d:X2} Dat{a:X2}");
}
else
{
//仮想レジスタに書き込み
work.OPM2vreg[d] = a;
//実レジスタに書き込み
chipRegister.setYM2151Register(1, 0, d, a, EnmModel.VirtualModel, 0, 0);
chipRegister.setYM2151Register(1, 0, d, a, model, 0, vgmFrameCounter);
//Console.WriteLine($"OPM2 Reg{d:X2} Dat{a:X2}");
}
}
Expand All @@ -906,28 +906,25 @@ private void wopm(byte d, byte a)
//仮想レジスタに書き込み
work.OPM1vreg[d] = a;
//実レジスタに書き込み
chipRegister.setYM2151Register(0, 0, d, a, EnmModel.RealModel, YM2151Hosei[0], 0);
chipRegister.setYM2151Register(0, 0, d, a, model, YM2151Hosei[0], vgmFrameCounter);
//Console.WriteLine($"OPM1 Reg{d:X2} Dat{a:X2}");
}
else
{
//仮想レジスタに書き込み
work.OPM2vreg[d] = a;
//実レジスタに書き込み
chipRegister.setYM2151Register(1, 0, d, a, EnmModel.RealModel, YM2151Hosei[1], 0);
chipRegister.setYM2151Register(1, 0, d, a, model, YM2151Hosei[1], vgmFrameCounter);
//Console.WriteLine($"OPM2 Reg{d:X2} Dat{a:X2}");
}
}
}

private void wpsg(byte d, byte a)
{
if (model == EnmModel.VirtualModel)
{
//Out(0x1c00, d);//PSG register
//Out(0x1b00, a);//PSG data
chipRegister.setAY8910Register(0, d, a, EnmModel.VirtualModel, vgmFrameCounter);
}
//Out(0x1c00, d);//PSG register
//Out(0x1b00, a);//PSG data
chipRegister.setAY8910Register(0, d, a, model, vgmFrameCounter);
//else
//{
//}
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/S98/S98.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private void WriteAY8910(int chipID, byte adr, byte data)

private void WriteSN76489(int chipID, byte data)
{
chipRegister.setSN76489Register(chipID, data, model, 0);
chipRegister.setSN76489Register(chipID, data, model, vgmFrameCounter);
}

private void WriteYMF262(int chipID, byte port, byte adr, byte data)
Expand Down
6 changes: 3 additions & 3 deletions MDPlayer/MDPlayerx64/form/SYS/frmPianoRoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void screenDrawParams()
int x;
int len;

tick = Audio.GetDriverCounter();
tick = Audio.GetVgmFrameCounter();
for (int i = 0; i < 8 * 12; i++)
{
int k = kn[i % kn.Length];
Expand All @@ -114,7 +114,7 @@ public void screenDrawParams()
x = (int)((n.startTick - tick + playLine) * mul);
len = (int)(n.endTick == -1 ? pbScreen.Width : ((n.endTick - tick + playLine) * mul) - x);

if (tick>=0 &&( x + len < 0 || len == 0))
if (tick >= 0 && (x + len < 0 || len == 0) && n.endTick != -1)
{
pianoRollMng.lstPrNote.RemoveAt(i);
i--;
Expand Down Expand Up @@ -175,7 +175,7 @@ public void screenDrawParams_V()
int y;
int len;

tick = Audio.GetDriverCounter();
tick = Audio.GetVgmFrameCounter();
for (int i = 0; i < 8 * 12; i++)
{
int k = kn[kn.Length-1-(i % kn.Length)];
Expand Down

0 comments on commit 5c11a9c

Please sign in to comment.