summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/wiping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/audio/wiping.cpp')
-rw-r--r--src/mame/audio/wiping.cpp52
1 files changed, 13 insertions, 39 deletions
diff --git a/src/mame/audio/wiping.cpp b/src/mame/audio/wiping.cpp
index 0b83b88f8ac..c5b667c3047 100644
--- a/src/mame/audio/wiping.cpp
+++ b/src/mame/audio/wiping.cpp
@@ -23,10 +23,7 @@ wiping_sound_device::wiping_sound_device(const machine_config &mconfig, const ch
m_sound_rom(nullptr),
m_num_voices(0),
m_sound_enable(0),
- m_stream(nullptr),
- m_mixer_table(nullptr),
- m_mixer_lookup(nullptr),
- m_mixer_buffer(nullptr)
+ m_stream(nullptr)
{
memset(m_channel_list, 0, sizeof(wp_sound_channel)*MAX_VOICES);
memset(m_soundregs, 0, sizeof(uint8_t)*0x4000);
@@ -42,13 +39,10 @@ void wiping_sound_device::device_start()
wp_sound_channel *voice;
/* get stream channels */
- m_stream = stream_alloc_legacy(0, 1, clock()/2);
+ m_stream = stream_alloc(0, 1, clock()/2);
/* allocate a buffer to mix into - 1 second's worth should be more than enough */
- m_mixer_buffer = make_unique_clear<short[]>(clock()/2);
-
- /* build the mixer table */
- make_mixer_table(8, defgain);
+ m_mixer_buffer.resize(clock()/2);
/* extract globals from the interface */
m_num_voices = 8;
@@ -81,26 +75,6 @@ void wiping_sound_device::device_start()
}
}
-/* build a table to divide by the number of voices; gain is specified as gain*16 */
-void wiping_sound_device::make_mixer_table(int voices, int gain)
-{
- /* allocate memory */
- m_mixer_table = make_unique_clear<int16_t[]>(256 * voices);
-
- /* find the middle of the table */
- m_mixer_lookup = m_mixer_table.get() + (128 * voices);
-
- /* fill in the table - 16 bit case */
- for (int i = 0; i < voices * 128; i++)
- {
- int val = i * gain * 16 / voices;
- if (val > 32767) val = 32767;
- m_mixer_lookup[ i] = val;
- m_mixer_lookup[-i] = -val;
- }
-}
-
-
/********************************************************************************/
void wiping_sound_device::sound_w(offs_t offset, uint8_t data)
@@ -150,12 +124,12 @@ void wiping_sound_device::sound_w(offs_t offset, uint8_t data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void wiping_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void wiping_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
wp_sound_channel *voice;
short *mix;
int i;
@@ -163,12 +137,12 @@ void wiping_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
/* if no sound, we're done */
if (m_sound_enable == 0)
{
- memset(buffer, 0, samples * sizeof(*buffer));
+ buffer.fill(0);
return;
}
/* zap the contents of the mixer buffer */
- memset(m_mixer_buffer.get(), 0, samples * sizeof(short));
+ std::fill_n(&m_mixer_buffer[0], buffer.samples(), 0);
/* loop over each voice and add its contribution */
for (voice = m_channel_list; voice < m_last_channel; voice++)
@@ -182,10 +156,10 @@ void wiping_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
const uint8_t *w = voice->wave;
int c = voice->counter;
- mix = m_mixer_buffer.get();
+ mix = &m_mixer_buffer[0];
/* add our contribution */
- for (i = 0; i < samples; i++)
+ for (i = 0; i < buffer.samples(); i++)
{
int offs;
@@ -229,7 +203,7 @@ void wiping_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}
/* mix it down */
- mix = m_mixer_buffer.get();
- for (i = 0; i < samples; i++)
- *buffer++ = m_mixer_lookup[*mix++];
+ mix = &m_mixer_buffer[0];
+ for (i = 0; i < buffer.samples(); i++)
+ buffer.put_int(i, *mix++, 128 * MAX_VOICES);
}