summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/c140.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/c140.cpp')
-rw-r--r--src/devices/sound/c140.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp
index 7f3780c8ed3..0edb1920a8c 100644
--- a/src/devices/sound/c140.cpp
+++ b/src/devices/sound/c140.cpp
@@ -77,9 +77,9 @@ DEFINE_DEVICE_TYPE(C219, c219_device, "c219", "Namco C219")
// LIVE DEVICE
//**************************************************************************
-static inline int limit(s32 in)
+static inline stream_buffer::sample_t limit(stream_buffer::sample_t in)
{
- return std::max(-0x7fff, std::min(0x8000, in));
+ return std::max(-1.0f, std::min(1.0f, in));
}
@@ -220,7 +220,7 @@ void c140_device::rom_bank_updated()
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void c140_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
s32 dt;
@@ -228,6 +228,7 @@ void c140_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
s16 *lmix, *rmix;
+ int samples = outputs[0].samples();
if (samples > m_sample_rate) samples = m_sample_rate;
/* zap the contents of the mixer buffer */
@@ -323,21 +324,22 @@ void c140_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
lmix = m_mixer_buffer_left.get();
rmix = m_mixer_buffer_right.get();
{
- stream_sample_t *dest1 = outputs[0];
- stream_sample_t *dest2 = outputs[1];
+ auto &dest1 = outputs[0];
+ auto &dest2 = outputs[1];
+ constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0;
for (int i = 0; i < samples; i++)
{
- s32 val;
+ stream_buffer::sample_t val;
- val = 8 * (*lmix++);
- *dest1++ = limit(val);
- val = 8 * (*rmix++);
- *dest2++ = limit(val);
+ val = stream_buffer::sample_t(*lmix++) * sample_scale;
+ dest1.put(i, limit(val));
+ val = stream_buffer::sample_t(*rmix++) * sample_scale;
+ dest2.put(i, limit(val));
}
}
}
-void c219_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
s32 dt;
@@ -345,6 +347,7 @@ void c219_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
s16 *lmix, *rmix;
+ int samples = outputs[0].samples();
if (samples > m_sample_rate) samples = m_sample_rate;
/* zap the contents of the mixer buffer */
@@ -460,16 +463,17 @@ void c219_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
lmix = m_mixer_buffer_left.get();
rmix = m_mixer_buffer_right.get();
{
- stream_sample_t *dest1 = outputs[0];
- stream_sample_t *dest2 = outputs[1];
+ auto &dest1 = outputs[0];
+ auto &dest2 = outputs[1];
+ constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0;
for (int i = 0; i < samples; i++)
{
- s32 val;
+ stream_buffer::sample_t val;
- val = 8 * (*lmix++);
- *dest1++ = limit(val);
- val = 8 * (*rmix++);
- *dest2++ = limit(val);
+ val = stream_buffer::sample_t(*lmix++) * sample_scale;
+ dest1.put(i, limit(val));
+ val = stream_buffer::sample_t(*rmix++) * sample_scale;
+ dest2.put(i, limit(val));
}
}
}