summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-14 01:20:20 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-14 01:20:20 -0700
commitd109811e3c6bcee6f0f6006bb94f9b3ccdc19871 (patch)
tree04eee97bd21fd1420a87a1a907c3fa40117a81db
parent72be63e246b6f4f4cfa991a47f7a23645ce403ad (diff)
Converted 'a' sound devices to new callbacks.
-rw-r--r--src/devices/sound/aica.cpp33
-rw-r--r--src/devices/sound/aica.h9
-rw-r--r--src/devices/sound/asc.cpp35
-rw-r--r--src/devices/sound/asc.h2
-rw-r--r--src/devices/sound/astrocde.cpp19
-rw-r--r--src/devices/sound/astrocde.h2
-rw-r--r--src/devices/sound/awacs.cpp25
-rw-r--r--src/devices/sound/awacs.h2
8 files changed, 53 insertions, 74 deletions
diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp
index 8d4ef4286cc..7bedf5d660a 100644
--- a/src/devices/sound/aica.cpp
+++ b/src/devices/sound/aica.cpp
@@ -1229,17 +1229,12 @@ s32 aica_device::UpdateSlot(AICA_SLOT *slot)
return sample;
}
-void aica_device::DoMasterSamples(int nsamples)
+void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr)
{
- stream_sample_t const *exts[2];
int i;
- stream_sample_t *bufr = m_bufferr;
- stream_sample_t *bufl = m_bufferl;
- exts[0] = m_exts0;
- exts[1] = m_exts1;
-
- for (int s = 0; s < nsamples; ++s)
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / stream_buffer::sample_t(32768 << SHIFT);
+ for (int s = 0; s < bufl.samples(); ++s)
{
s32 smpl = 0, smpr = 0;
@@ -1280,7 +1275,7 @@ void aica_device::DoMasterSamples(int nsamples)
{
if (EFSDL(i + 16)) // 16,17 for EXTS
{
- m_DSP.EXTS[i] = exts[i][s];
+ m_DSP.EXTS[i] = s16(inputs[i].get(s) * 32767.0);
u32 Enc = ((EFPAN(i + 16)) << 0x8) | ((EFSDL(i + 16)) << 0xd);
smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT;
smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT;
@@ -1298,8 +1293,8 @@ void aica_device::DoMasterSamples(int nsamples)
smpr = clip16(smpr >> 3);
}
- *bufl++ = (smpl * m_LPANTABLE[MVOL() << 0xd]) >> SHIFT;
- *bufr++ = (smpr * m_LPANTABLE[MVOL() << 0xd]) >> SHIFT;
+ bufl.put(s, stream_buffer::sample_t(smpl * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
+ bufr.put(s, stream_buffer::sample_t(smpr * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
}
}
@@ -1390,16 +1385,12 @@ int aica_device::IRQCB(void *param)
#endif
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void aica_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void aica_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- m_bufferl = outputs[0];
- m_bufferr = outputs[1];
- m_exts0 = inputs[0];
- m_exts1 = inputs[1];
- DoMasterSamples(samples);
+ DoMasterSamples(inputs, outputs[0], outputs[1]);
}
//-------------------------------------------------
@@ -1418,7 +1409,7 @@ void aica_device::device_start()
m_irq_cb.resolve_safe();
m_main_irq_cb.resolve_safe();
- m_stream = stream_alloc_legacy(2, 2, (int)m_rate);
+ m_stream = stream_alloc(2, 2, (int)m_rate);
// save state
save_item(NAME(m_udata.data));
@@ -1568,10 +1559,6 @@ aica_device::aica_device(const machine_config &mconfig, const char *tag, device_
, m_MidiR(0)
, m_mcieb(0)
, m_mcipd(0)
- , m_bufferl(nullptr)
- , m_bufferr(nullptr)
- , m_exts0(nullptr)
- , m_exts1(nullptr)
{
memset(&m_udata.data, 0, sizeof(m_udata.data));
diff --git a/src/devices/sound/aica.h b/src/devices/sound/aica.h
index 8b4aaee49d9..8509953a228 100644
--- a/src/devices/sound/aica.h
+++ b/src/devices/sound/aica.h
@@ -39,7 +39,7 @@ protected:
virtual void device_clock_changed() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
// device_memory_interface configuration
virtual space_config_vector memory_space_config() const override;
@@ -124,7 +124,7 @@ private:
void w16(u32 addr,u16 val);
u16 r16(u32 addr);
inline s32 UpdateSlot(AICA_SLOT *slot);
- void DoMasterSamples(int nsamples);
+ void DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr);
void exec_dma();
@@ -184,11 +184,6 @@ private:
AICADSP m_DSP;
- stream_sample_t *m_bufferl;
- stream_sample_t *m_bufferr;
- stream_sample_t const *m_exts0;
- stream_sample_t const *m_exts1;
-
s32 m_EG_TABLE[0x400];
int m_PLFO_TRI[256],m_PLFO_SQR[256],m_PLFO_SAW[256],m_PLFO_NOI[256];
int m_ALFO_TRI[256],m_ALFO_SQR[256],m_ALFO_SAW[256],m_ALFO_NOI[256];
diff --git a/src/devices/sound/asc.cpp b/src/devices/sound/asc.cpp
index ca794ca01e5..79c13c90836 100644
--- a/src/devices/sound/asc.cpp
+++ b/src/devices/sound/asc.cpp
@@ -62,7 +62,7 @@ asc_device::asc_device(const machine_config &mconfig, const char *tag, device_t
void asc_device::device_start()
{
// create the stream
- m_stream = stream_alloc_legacy(0, 2, 22257);
+ m_stream = stream_alloc(0, 2, 22257);
memset(m_regs, 0, sizeof(m_regs));
@@ -113,26 +113,23 @@ void asc_device::device_timer(emu_timer &timer, device_timer_id tid, int param,
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void asc_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *outL, *outR;
int i, ch;
static uint32_t wtoffs[2] = { 0, 0x200 };
- outL = outputs[0];
- outR = outputs[1];
+ auto &outL = outputs[0];
+ auto &outR = outputs[1];
switch (m_regs[R_MODE-0x800] & 3)
{
case 0: // chip off
- for (i = 0; i < samples; i++)
- {
- outL[i] = outR[i] = 0;
- }
+ outL.fill(0);
+ outR.fill(0);
// IIvx/IIvi bootrom indicates VASP updates this flag even when the chip is off
if (m_chip_type == asc_type::VASP)
@@ -145,7 +142,9 @@ void asc_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_
break;
case 1: // FIFO mode
- for (i = 0; i < samples; i++)
+ {
+ constexpr stream_buffer::sample_t sample_scale = 64.0 / 32768.0;
+ for (i = 0; i < outL.samples(); i++)
{
int8_t smpll, smplr;
@@ -230,13 +229,16 @@ void asc_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_
break;
}
- outL[i] = smpll * 64;
- outR[i] = smplr * 64;
+ outL.put(i, stream_buffer::sample_t(smpll) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(smplr) * sample_scale);
}
break;
+ }
case 2: // wavetable mode
- for (i = 0; i < samples; i++)
+ {
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / (32768.0 * 4.0);
+ for (i = 0; i < outL.samples(); i++)
{
int32_t mixL, mixR;
int8_t smpl;
@@ -262,10 +264,11 @@ void asc_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_
mixR += smpl*256;
}
- outL[i] = mixL>>2;
- outR[i] = mixR>>2;
+ outL.put(i, stream_buffer::sample_t(mixL) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(mixR) * sample_scale);
}
break;
+ }
}
// printf("rdA %04x rdB %04x wrA %04x wrB %04x (capA %04x B %04x)\n", m_fifo_a_rdptr, m_fifo_b_rdptr, m_fifo_a_wrptr, m_fifo_b_wrptr, m_fifo_cap_a, m_fifo_cap_b);
diff --git a/src/devices/sound/asc.h b/src/devices/sound/asc.h
index bb9904d6185..f1dff62ffc2 100644
--- a/src/devices/sound/asc.h
+++ b/src/devices/sound/asc.h
@@ -76,7 +76,7 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
devcb_write_line write_irq;
diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp
index c377f40440b..17df6999989 100644
--- a/src/devices/sound/astrocde.cpp
+++ b/src/devices/sound/astrocde.cpp
@@ -117,7 +117,7 @@ void astrocade_io_device::device_start()
m_bitswap[i] = bitswap<8>(i, 0,1,2,3,4,5,6,7);
/* allocate a stream for output */
- m_stream = stream_alloc_legacy(0, 1, clock());
+ m_stream = stream_alloc(0, 1, clock());
/* reset state */
device_reset();
@@ -129,9 +129,9 @@ void astrocade_io_device::device_start()
// sound_stream_update_legacy - handle a stream update
//-------------------------------------------------
-void astrocade_io_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *dest = outputs[0];
+ auto &dest = outputs[0];
uint16_t noise_state;
uint8_t master_count;
uint8_t noise_clock;
@@ -142,17 +142,16 @@ void astrocade_io_device::sound_stream_update_legacy(sound_stream &stream, strea
noise_state = m_noise_state;
/* loop over samples */
- while (samples > 0)
+ int samples_this_time;
+ constexpr stream_buffer::sample_t sample_scale = 1.0f / 60.0f;
+ for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time)
{
stream_sample_t cursample = 0;
- int samples_this_time;
- int samp;
/* compute the number of cycles until the next master oscillator reset */
/* or until the next noise boundary */
- samples_this_time = std::min(samples, 256 - master_count);
+ samples_this_time = std::min<int>(dest.samples() - sampindex, 256 - master_count);
samples_this_time = std::min(samples_this_time, 64 - noise_clock);
- samples -= samples_this_time;
/* sum the output of the tone generators */
if (m_a_state)
@@ -167,9 +166,7 @@ void astrocade_io_device::sound_stream_update_legacy(sound_stream &stream, strea
cursample += m_reg[7] >> 4;
/* scale to max and output */
- cursample = cursample * 32767 / 60;
- for (samp = 0; samp < samples_this_time; samp++)
- *dest++ = cursample;
+ dest.fill(stream_buffer::sample_t(cursample) * sample_scale, sampindex, samples_this_time);
/* clock the noise; a 2-bit counter clocks a 4-bit counter which clocks the LFSR */
noise_clock += samples_this_time;
diff --git a/src/devices/sound/astrocde.h b/src/devices/sound/astrocde.h
index c93788699e0..387ef7f9ca3 100644
--- a/src/devices/sound/astrocde.h
+++ b/src/devices/sound/astrocde.h
@@ -58,7 +58,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
public:
void write(offs_t offset, uint8_t data);
diff --git a/src/devices/sound/awacs.cpp b/src/devices/sound/awacs.cpp
index 1453fbd2305..19f734cd468 100644
--- a/src/devices/sound/awacs.cpp
+++ b/src/devices/sound/awacs.cpp
@@ -42,7 +42,7 @@ awacs_device::awacs_device(const machine_config &mconfig, const char *tag, devic
void awacs_device::device_start()
{
// create the stream
- m_stream = stream_alloc_legacy(0, 2, 22050);
+ m_stream = stream_alloc(0, 2, 22050);
memset(m_regs, 0, sizeof(m_regs));
@@ -82,24 +82,24 @@ void awacs_device::device_timer(emu_timer &timer, device_timer_id tid, int param
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void awacs_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *outL, *outR;
int offset = (m_buffer_num == 0) ? m_dma_offset_0 : m_dma_offset_1;
- outL = outputs[0];
- outR = outputs[1];
+ auto &outL = outputs[0];
+ auto &outR = outputs[1];
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
if (m_playback_enable)
{
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < outL.samples(); i++)
{
- outL[i] = (int16_t)m_dma_space->read_word(offset + m_play_ptr);
- outR[i] = (int16_t)m_dma_space->read_word(offset + m_play_ptr + 2);
+ outL.put(i, stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr))) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr + 2))) * sample_scale);
m_play_ptr += 4;
}
@@ -115,11 +115,8 @@ void awacs_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl
}
else
{
- for (int i = 0; i < samples; i++)
- {
- outL[i] = 0;
- outR[i] = 0;
- }
+ outL.fill(0);
+ outR.fill(0);
}
}
diff --git a/src/devices/sound/awacs.h b/src/devices/sound/awacs.h
index 6c85317ddfa..0840d21d0d9 100644
--- a/src/devices/sound/awacs.h
+++ b/src/devices/sound/awacs.h
@@ -36,7 +36,7 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
sound_stream *m_stream;