summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/multipcm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/multipcm.cpp')
-rw-r--r--src/devices/sound/multipcm.cpp68
1 files changed, 24 insertions, 44 deletions
diff --git a/src/devices/sound/multipcm.cpp b/src/devices/sound/multipcm.cpp
index 6698792fbe1..4ea099b947a 100644
--- a/src/devices/sound/multipcm.cpp
+++ b/src/devices/sound/multipcm.cpp
@@ -450,22 +450,22 @@ void multipcm_device::write(offs_t offset, uint8_t data)
DEFINE_DEVICE_TYPE(MULTIPCM, multipcm_device, "ymw258f", "Yamaha YMW-258-F")
-multipcm_device::multipcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, MULTIPCM, tag, owner, clock),
- device_sound_interface(mconfig, *this),
- device_rom_interface(mconfig, *this),
- m_stream(nullptr),
- m_slots(nullptr),
- m_cur_slot(0),
- m_address(0),
- m_rate(0),
- m_attack_step(nullptr),
- m_decay_release_step(nullptr),
- m_freq_step_table(nullptr),
- m_left_pan_table(nullptr),
- m_right_pan_table(nullptr),
- m_linear_to_exp_volume(nullptr),
- m_total_level_steps(nullptr)
+multipcm_device::multipcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, MULTIPCM, tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ device_rom_interface(mconfig, *this),
+ m_stream(nullptr),
+ m_slots(nullptr),
+ m_cur_slot(0),
+ m_address(0),
+ m_rate(0),
+ m_attack_step(nullptr),
+ m_decay_release_step(nullptr),
+ m_freq_step_table(nullptr),
+ m_left_pan_table(nullptr),
+ m_right_pan_table(nullptr),
+ m_linear_to_exp_volume(nullptr),
+ m_total_level_steps(nullptr)
{
}
@@ -479,7 +479,7 @@ void multipcm_device::device_start()
const float clock_divider = 180.0f;
m_rate = (float)clock() / clock_divider;
- m_stream = machine().sound().stream_alloc(*this, 0, 2, m_rate);
+ m_stream = stream_alloc(0, 2, m_rate);
// Volume + pan table
m_left_pan_table = make_unique_clear<int32_t[]>(0x800);
@@ -575,7 +575,7 @@ void multipcm_device::device_start()
save_item(NAME(m_address));
// Slots
- m_slots = make_unique_clear<slot_t []>(28);
+ m_slots = std::make_unique<slot_t []>(28);
save_pointer(STRUCT_MEMBER(m_slots, m_regs), 28);
save_pointer(STRUCT_MEMBER(m_slots, m_playing), 28);
@@ -628,22 +628,10 @@ void multipcm_device::device_clock_changed()
}
//-----------------------------------------------------
-// clamp_to_int16 - clamp a 32-bit value to 16 bits
+// convert_to_stream_sample - clamp a 32-bit value to
+// 16 bits and convert to a stream_buffer::sample_t
//-----------------------------------------------------
-int16_t multipcm_device::clamp_to_int16(int32_t value)
-{
- if (value < -32768)
- {
- return -32768;
- }
- else if (value > 32767)
- {
- return 32767;
- }
- return (int16_t)value;
-}
-
#if MULTIPCM_LOG_SAMPLES
void multipcm_device::dump_sample(slot_t &slot)
{
@@ -680,17 +668,9 @@ void multipcm_device::dump_sample(slot_t &slot)
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void multipcm_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int32_t samples)
+void multipcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *datap[2];
-
- datap[0] = outputs[0];
- datap[1] = outputs[1];
-
- memset(datap[0], 0, sizeof(*datap[0]) * samples);
- memset(datap[1], 0, sizeof(*datap[1]) * samples);
-
- for (int32_t i = 0; i < samples; ++i)
+ for (int32_t i = 0; i < outputs[0].samples(); ++i)
{
int32_t smpl = 0;
int32_t smpr = 0;
@@ -741,8 +721,8 @@ void multipcm_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
}
- datap[0][i] = clamp_to_int16(smpl);
- datap[1][i] = clamp_to_int16(smpr);
+ outputs[0].put_int_clamp(i, smpl, 32768);
+ outputs[1].put_int_clamp(i, smpr, 32768);
}
}