summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/qsoundhle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/qsoundhle.cpp')
-rw-r--r--src/devices/sound/qsoundhle.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/devices/sound/qsoundhle.cpp b/src/devices/sound/qsoundhle.cpp
index e332add2977..ed69b569cb5 100644
--- a/src/devices/sound/qsoundhle.cpp
+++ b/src/devices/sound/qsoundhle.cpp
@@ -42,7 +42,7 @@ ROM_END
qsound_hle_device::qsound_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, QSOUND_HLE, tag, owner, clock)
, device_sound_interface(mconfig, *this)
- , device_rom_interface(mconfig, *this, 24)
+ , device_rom_interface(mconfig, *this)
, m_stream(nullptr)
, m_dsp_rom(*this, "dsp")
, m_data_latch(0)
@@ -50,10 +50,11 @@ qsound_hle_device::qsound_hle_device(const machine_config &mconfig, const char *
}
//-------------------------------------------------
-// rom_bank_updated - the rom bank has changed
+// rom_bank_pre_change - refresh the stream if the
+// ROM banking changes
//-------------------------------------------------
-void qsound_hle_device::rom_bank_updated()
+void qsound_hle_device::rom_bank_pre_change()
{
m_stream->update();
}
@@ -161,17 +162,13 @@ void qsound_hle_device::device_reset()
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void qsound_hle_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void qsound_hle_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- // Clear the buffers
- std::fill_n(outputs[0], samples, 0);
- std::fill_n(outputs[1], samples, 0);
-
- for (int i = 0; i < samples; i ++)
+ for (int i = 0; i < outputs[0].samples(); i ++)
{
update_sample();
- outputs[0][i] = m_out[0];
- outputs[1][i] = m_out[1];
+ outputs[0].put_int(i, m_out[0], 32768);
+ outputs[1].put_int(i, m_out[1], 32768);
}
}
@@ -420,7 +417,7 @@ int16_t qsound_hle_device::qsound_voice::update(qsound_hle_device &dsp, int32_t
if ((new_phase >> 12) >= m_end_addr)
new_phase -= (m_loop_len << 12);
- new_phase = std::min<int32_t>(std::max<int32_t>(new_phase, -0x8000000), 0x7FFFFFF);
+ new_phase = std::clamp<int32_t>(new_phase, -0x8000000, 0x7FFFFFF);
m_addr = new_phase >> 12;
m_phase = (new_phase << 4)&0xffff;
@@ -469,10 +466,10 @@ int16_t qsound_hle_device::qsound_adpcm::update(qsound_hle_device &dsp, int16_t
if (step <= 0)
delta = -delta;
delta += curr_sample;
- delta = std::min<int32_t>(std::max<int32_t>(delta, -32768), 32767);
+ delta = std::clamp<int32_t>(delta, -32768, 32767);
m_step_size = (dsp.read_dsp_rom(DATA_ADPCM_TAB + 8 + step) * m_step_size) >> 6;
- m_step_size = std::min<int16_t>(std::max<int16_t>(m_step_size, 1), 2000);
+ m_step_size = std::clamp<int16_t>(m_step_size, 1, 2000);
return (delta * m_cur_vol) >> 16;
}
@@ -508,7 +505,7 @@ void qsound_hle_device::state_normal_update()
else
m_echo.m_length = m_echo.m_end_pos - DELAY_BASE_OFFSET;
- m_echo.m_length = std::min<int16_t>(std::max<int16_t>(m_echo.m_length, 0), 1024);
+ m_echo.m_length = std::clamp<int16_t>(m_echo.m_length, 0, 1024);
// update PCM voices
int32_t echo_input = 0;
@@ -538,8 +535,8 @@ void qsound_hle_device::state_normal_update()
wet -= (m_voice_output[i] * (int16_t)read_dsp_rom(pan_index + PAN_TABLE_WET));
}
// Saturate accumulated voices
- dry = (std::min<int32_t>(std::max<int32_t>(dry, -0x1fffffff), 0x1fffffff)) << 2;
- wet = (std::min<int32_t>(std::max<int32_t>(wet, -0x1fffffff), 0x1fffffff)) << 2;
+ dry = std::clamp<int32_t>(dry, -0x1fffffff, 0x1fffffff) << 2;
+ wet = std::clamp<int32_t>(wet, -0x1fffffff, 0x1fffffff) << 2;
// Apply FIR filter on 'wet' input
wet = m_filter[ch].apply(wet >> 16);
@@ -553,7 +550,7 @@ void qsound_hle_device::state_normal_update()
// DSP round function
output = (output + 0x2000) & ~0x3fff;
- m_out[ch] = (std::min<int32_t>(std::max<int32_t>(output >> 14, -0x7fff), 0x7fff));
+ m_out[ch] = std::clamp<int32_t>(output >> 14, -0x7fff, 0x7fff);
if (m_delay_update)
{