From ee709b85c2bbdc7b7e3aedb41c19426852df565b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 20 Jun 2022 18:20:49 -0500 Subject: [PATCH] Namco WSG: per-channel oscilloscope --- src/engine/platform/namcowsg.cpp | 13 +++++++++---- src/engine/platform/sound/namco.cpp | 9 +++++---- src/engine/platform/sound/namco.h | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/engine/platform/namcowsg.cpp b/src/engine/platform/namcowsg.cpp index 1e8ff46d..43136d91 100644 --- a/src/engine/platform/namcowsg.cpp +++ b/src/engine/platform/namcowsg.cpp @@ -164,9 +164,6 @@ const char* DivPlatformNamcoWSG::getEffectName(unsigned char effect) { } void DivPlatformNamcoWSG::acquire(short* bufL, short* bufR, size_t start, size_t len) { - short* buf[2]={ - bufL+start, bufR+start - }; while (!writes.empty()) { QueuedWrite w=writes.front(); switch (devType) { @@ -186,7 +183,15 @@ void DivPlatformNamcoWSG::acquire(short* bufL, short* bufR, size_t start, size_t regPool[w.addr&0x3f]=w.val; writes.pop(); } - namco->sound_stream_update(buf,len); + for (size_t h=start; hsound_stream_update(buf,1); + for (int i=0; idata[oscBuf[i]->needle++]=namco->m_channel_list[i].last_out*chans; + } + } } void DivPlatformNamcoWSG::updateWave(int ch) { diff --git a/src/engine/platform/sound/namco.cpp b/src/engine/platform/sound/namco.cpp index 82141301..811c34ab 100644 --- a/src/engine/platform/sound/namco.cpp +++ b/src/engine/platform/sound/namco.cpp @@ -172,10 +172,11 @@ void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase) /* generate sound by oversampling */ -uint32_t namco_audio_device::namco_update_one(short* buffer, int size, const int16_t *wave, uint32_t counter, uint32_t freq) +uint32_t namco_audio_device::namco_update_one(short* buffer, int size, const int16_t *wave, uint32_t counter, uint32_t freq, int16_t& last_out) { for (int sampindex = 0; sampindex < size; sampindex++) { + last_out=wave[WAVEFORM_POSITION(counter)]; buffer[sampindex]+=wave[WAVEFORM_POSITION(counter)]; counter += freq; } @@ -700,7 +701,7 @@ void namco_audio_device::sound_stream_update(short** outputs, int len) const int16_t *lw = &m_waveform[lv][voice->waveform_select * 32]; /* generate sound into the buffer */ - c = namco_update_one(lmix, len, lw, voice->counter, voice->frequency); + c = namco_update_one(lmix, len, lw, voice->counter, voice->frequency, voice->last_out); } /* only update if we have non-zero right volume */ @@ -709,7 +710,7 @@ void namco_audio_device::sound_stream_update(short** outputs, int len) const int16_t *rw = &m_waveform[rv][voice->waveform_select * 32]; /* generate sound into the buffer */ - c = namco_update_one(rmix, len, rw, voice->counter, voice->frequency); + c = namco_update_one(rmix, len, rw, voice->counter, voice->frequency, voice->last_out); } /* update the counter for this voice */ @@ -789,7 +790,7 @@ void namco_audio_device::sound_stream_update(short** outputs, int len) const int16_t *w = &m_waveform[v][voice->waveform_select * 32]; /* generate sound into buffer and update the counter for this voice */ - voice->counter = namco_update_one(buffer, len, w, voice->counter, voice->frequency); + voice->counter = namco_update_one(buffer, len, w, voice->counter, voice->frequency, voice->last_out); } } } diff --git a/src/engine/platform/sound/namco.h b/src/engine/platform/sound/namco.h index 507eaed2..d3844abc 100644 --- a/src/engine/platform/sound/namco.h +++ b/src/engine/platform/sound/namco.h @@ -31,6 +31,7 @@ public: uint32_t noise_counter; int32_t noise_hold; int32_t waveform_select; + int16_t last_out; }; namco_audio_device(uint32_t clock); @@ -43,7 +44,7 @@ public: void build_decoded_waveform( uint8_t *rgnbase ); void update_namco_waveform(int offset, uint8_t data); - uint32_t namco_update_one(short* buffer, int size, const int16_t *wave, uint32_t counter, uint32_t freq); + uint32_t namco_update_one(short* buffer, int size, const int16_t *wave, uint32_t counter, uint32_t freq, int16_t& last_out); /* waveform region */ uint8_t* m_wave_ptr;