summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/ics2115.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/ics2115.cpp')
-rw-r--r--src/devices/sound/ics2115.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp
index fa570814019..98c5916c253 100644
--- a/src/devices/sound/ics2115.cpp
+++ b/src/devices/sound/ics2115.cpp
@@ -63,7 +63,7 @@ void ics2115_device::device_start()
m_timer[0].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_0),this), this);
m_timer[1].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_1),this), this);
- m_stream = stream_alloc_legacy(0, 2, clock() / (32 * 32));
+ m_stream = stream_alloc(0, 2, clock() / (32 * 32));
m_irq_cb.resolve_safe();
@@ -316,7 +316,7 @@ int ics2115_device::ics2115_voice::update_oscillator()
}
//TODO: proper interpolation for 8-bit samples (looping)
-stream_sample_t ics2115_device::get_sample(ics2115_voice& voice)
+s32 ics2115_device::get_sample(ics2115_voice& voice)
{
const u32 curaddr = voice.osc.acc >> 12;
u32 nextaddr;
@@ -385,13 +385,14 @@ void ics2115_device::ics2115_voice::update_ramp()
}
}
-int ics2115_device::fill_output(ics2115_voice& voice, stream_sample_t * const outputs[2], int samples)
+int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_view> &outputs)
{
bool irq_invalid = false;
const u16 fine = 1 << (3*(voice.vol.incr >> 6));
voice.vol.add = (voice.vol.incr & 0x3f)<< (10 - fine);
- for (int i = 0; i < samples; i++)
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / (32768.0 * (1 << (5 + volume_bits)));
+ for (int i = 0; i < outputs[0].samples(); i++)
{
const u32 volacc = (voice.vol.acc >> 10) & 0xffff;
const u32 volume = (m_volume[volacc >> 4] * voice.state.ramp) >> 6;
@@ -403,15 +404,15 @@ int ics2115_device::fill_output(ics2115_voice& voice, stream_sample_t * const ou
//final output, even if they are not running. This means that whatever data value
//that the voice is pointing at is contributing to the summation.
//(austere note: this will of course fix some of the glitches due to multiple transition)
- stream_sample_t sample = get_sample(voice);
+ s32 sample = get_sample(voice);
//15-bit volume + (5-bit worth of 32 channel sum) + 16-bit samples = 4-bit extra
if (!m_vmode || voice.playing())
{
/*if (voice.playing())
{*/
- outputs[0][i] += (sample * vleft) >> (5 + volume_bits - 16);
- outputs[1][i] += (sample * vright) >> (5 + volume_bits - 16);
+ outputs[0].add(i, stream_buffer::sample_t(sample * vleft) * sample_scale);
+ outputs[1].add(i, stream_buffer::sample_t(sample * vright) * sample_scale);
}
voice.update_ramp();
@@ -426,10 +427,10 @@ int ics2115_device::fill_output(ics2115_voice& voice, stream_sample_t * const ou
return irq_invalid;
}
-void ics2115_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- memset(outputs[0], 0, samples * sizeof(stream_sample_t));
- memset(outputs[1], 0, samples * sizeof(stream_sample_t));
+ outputs[0].fill(0);
+ outputs[1].fill(0);
bool irq_invalid = false;
for (int osc = 0; osc <= m_active_osc; osc++)
@@ -447,7 +448,7 @@ void ics2115_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
logerror("[%06x=%04x]", curaddr, (s16)sample);
#endif
*/
- if (fill_output(voice, outputs, samples))
+ if (fill_output(voice, outputs))
irq_invalid = true;
#ifdef ICS2115_DEBUG
@@ -479,13 +480,6 @@ void ics2115_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
logerror("|");
#endif
- //rescale
- for (int i = 0; i < samples; i++)
- {
- outputs[0][i] >>= 16;
- outputs[1][i] >>= 16;
- }
-
if (irq_invalid)
recalc_irq();