summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/es5503.cpp
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-17 20:41:21 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-17 20:41:21 -0700
commit54beaa97ff31ec20e10c17737e2be93a5862827b (patch)
treea5b376abe3a3991a5c21623389220d7c719f70b2 /src/devices/sound/es5503.cpp
parent594d58d6a267895e475c51a9ca0e4757ef7e9445 (diff)
es1373/es5503/es5506/esqpump: update to new stream callbacks
Diffstat (limited to 'src/devices/sound/es5503.cpp')
-rw-r--r--src/devices/sound/es5503.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/devices/sound/es5503.cpp b/src/devices/sound/es5503.cpp
index 36fcaaf8af1..4ffc0d263a3 100644
--- a/src/devices/sound/es5503.cpp
+++ b/src/devices/sound/es5503.cpp
@@ -128,18 +128,19 @@ void es5503_device::halt_osc(int onum, int type, uint32_t *accumulator, int ress
}
}
-void es5503_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void es5503_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- static int32_t mix[(44100/60)*2*8];
int32_t *mixp;
int osc, snum, i;
uint32_t ramptr;
- assert(samples < (44100/60)*2);
- memset(mix, 0, sizeof(mix));
+ if (m_mix_buffer.size() < outputs[0].samples())
+ m_mix_buffer.resize(outputs[0].samples());
for (int chan = 0; chan < output_channels; chan++)
{
+ std::fill_n(&m_mix_buffer[0], outputs[0].samples(), 0);
+
for (osc = 0; osc < (oscsenabled+1); osc++)
{
ES5503Osc *pOsc = &oscillators[osc];
@@ -155,9 +156,9 @@ void es5503_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
int8_t data = -128;
int resshift = resshifts[pOsc->resolution] - pOsc->wavetblsize;
uint32_t sizemask = accmasks[pOsc->wavetblsize];
- mixp = &mix[0] + chan;
+ mixp = &m_mix_buffer[0];
- for (snum = 0; snum < samples; snum++)
+ for (snum = 0; snum < outputs[0].samples(); snum++)
{
altram = acc >> resshift;
ramptr = altram & sizemask;
@@ -175,7 +176,7 @@ void es5503_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
else
{
*mixp += data * vol;
- mixp += output_channels;
+ mixp++;
if (altram >= wtsize)
{
@@ -196,12 +197,12 @@ void es5503_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
pOsc->data = data ^ 0x80;
}
}
- }
- mixp = &mix[0];
- for (i = 0; i < samples; i++)
- for (int chan = 0; chan < output_channels; chan++)
- outputs[chan][i] = (*mixp++)>>3;
+ mixp = &m_mix_buffer[0];
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / (32768.0 * 8.0);
+ for (i = 0; i < outputs[chan].samples(); i++)
+ outputs[chan].put(i, stream_buffer::sample_t(*mixp++) * sample_scale);
+ }
}
@@ -224,7 +225,7 @@ void es5503_device::device_start()
save_pointer(STRUCT_MEMBER(oscillators, irqpend), 32);
output_rate = (clock() / 8) / (2 + oscsenabled);
- m_stream = stream_alloc_legacy(0, output_channels, output_rate);
+ m_stream = stream_alloc(0, output_channels, output_rate);
m_timer = timer_alloc(0, nullptr);
attotime update_rate = output_rate ? attotime::from_hz(output_rate) : attotime::never;