From de09073232f20fe82166d85d2d73f1b58bc6c48b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 2 May 2022 00:05:28 -0500 Subject: [PATCH] NES: NSFPlay per-channel osc --- src/engine/platform/nes.cpp | 8 ++++++++ src/engine/platform/sound/nes_nsfplay/nes_apu.h | 2 +- src/engine/platform/sound/nes_nsfplay/nes_dmc.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index e353b26dc..8ca8d1f1c 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -154,6 +154,14 @@ void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, siz if (sample>32767) sample=32767; if (sample<-32768) sample=-32768; bufL[i]=sample; + if (++writeOscBuf>=32) { + writeOscBuf=0; + oscBuf[0]->data[oscBuf[0]->needle++]=nes1_NP->out[0]<<11; + oscBuf[1]->data[oscBuf[1]->needle++]=nes1_NP->out[1]<<11; + oscBuf[2]->data[oscBuf[2]->needle++]=nes2_NP->out[0]<<11; + oscBuf[3]->data[oscBuf[3]->needle++]=nes2_NP->out[1]<<11; + oscBuf[4]->data[oscBuf[4]->needle++]=nes2_NP->out[2]<<8; + } } } diff --git a/src/engine/platform/sound/nes_nsfplay/nes_apu.h b/src/engine/platform/sound/nes_nsfplay/nes_apu.h index b302dd02c..20c4d3663 100644 --- a/src/engine/platform/sound/nes_nsfplay/nes_apu.h +++ b/src/engine/platform/sound/nes_nsfplay/nes_apu.h @@ -27,7 +27,6 @@ namespace xgm unsigned int gclock; unsigned char reg[0x20]; - int out[2]; double rate, clock; int square_table[32]; // nonlinear mixer @@ -63,6 +62,7 @@ namespace xgm int calc_sqr (int ch, unsigned int clocks); public: + int out[2]; NES_APU (); ~NES_APU (); diff --git a/src/engine/platform/sound/nes_nsfplay/nes_dmc.h b/src/engine/platform/sound/nes_nsfplay/nes_dmc.h index b0aa2ef92..f78dd9f4a 100644 --- a/src/engine/platform/sound/nes_nsfplay/nes_dmc.h +++ b/src/engine/platform/sound/nes_nsfplay/nes_dmc.h @@ -36,7 +36,6 @@ namespace xgm unsigned int len_reg; unsigned int adr_reg; std::function memory; - unsigned int out[3]; unsigned int daddress; unsigned int dlength; unsigned int data; @@ -91,6 +90,7 @@ namespace xgm inline unsigned int calc_noise (unsigned int clocks); public: + unsigned int out[3]; NES_DMC (); ~NES_DMC ();