summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Aaron Giles <aaronsgiles@users.noreply.github.com>2020-09-27 20:46:58 -0700
committerGravatarGravatar GitHub <noreply@github.com>2020-09-28 13:46:58 +1000
commit7b8913fefa46d67e4be7c662f20a4e26e21000eb (patch)
tree5e8e471549b9c640aca9ba995de7e0c470154581
parent52514f1acd4c825aee93acb93b286af1c8712807 (diff)
Complete sound modernization of remaining devices. Legacy callbacks and stream_sample_t removed. (#7297)
* a2mcms/coco_ssc/gus/cassette/floppy/8364_paula/laserdsc/s2636/spg2xx_audio/arcadia/channelf/cmi01a/cps3/dai_snd: Update to new stream callbacks * dsbz80/elan_eu3a05/exidy/exidy440/flower/geebee/gomoku/gridlee: Update to new stream callbacks * hyprolyb/lynx/micro3d/phoenix/pleiads/polepos: Update to new sound stream callback * redbaron/segag80r/segausb/seibu/snk6502/socrates/special/svis_snd: Update to new stream callbacks. * tiamc1/turrett/tvc/tx1/vboy/vc4000: Update to new stream callbacks * warpwarp/wiping/wswan/xavix/esq1/istrebiteli/milton6805/pv1000/mega32x/gic: Update to new stream callback * sound: Remove legacy stream support and stream_sample_t * * gomoku/wiping: Remove silly mixer tables in favor of math * micro3d: Remove tiny vectors in favor of fixed arrays * phoenix: Went back to std::unique_ptr array for LFSR * wiping: Fixed the scale factor.
-rw-r--r--src/devices/bus/a2bus/a2mcms.cpp21
-rw-r--r--src/devices/bus/a2bus/a2mcms.h2
-rw-r--r--src/devices/bus/coco/coco_ssc.cpp22
-rw-r--r--src/devices/bus/isa/gus.cpp25
-rw-r--r--src/devices/bus/isa/gus.h2
-rw-r--r--src/devices/imagedev/cassette.cpp30
-rw-r--r--src/devices/imagedev/cassette.h3
-rw-r--r--src/devices/imagedev/floppy.cpp12
-rw-r--r--src/devices/imagedev/floppy.h2
-rw-r--r--src/devices/machine/8364_paula.cpp14
-rw-r--r--src/devices/machine/8364_paula.h2
-rw-r--r--src/devices/machine/laserdsc.cpp35
-rw-r--r--src/devices/machine/laserdsc.h2
-rw-r--r--src/devices/machine/s2636.cpp13
-rw-r--r--src/devices/machine/s2636.h2
-rw-r--r--src/devices/machine/spg2xx_audio.cpp14
-rw-r--r--src/devices/machine/spg2xx_audio.h2
-rw-r--r--src/devices/sound/astrocde.cpp2
-rw-r--r--src/devices/sound/dac76.cpp2
-rw-r--r--src/devices/sound/discrete.cpp2
-rw-r--r--src/devices/sound/es5503.h1
-rw-r--r--src/devices/sound/fm.h2
-rw-r--r--src/devices/sound/fmopl.h2
-rw-r--r--src/devices/sound/ics2115.cpp2
-rw-r--r--src/devices/sound/k053260.cpp4
-rw-r--r--src/devices/sound/k053260.h2
-rw-r--r--src/devices/sound/s_dsp.cpp4
-rw-r--r--src/devices/sound/ymf262.h2
-rw-r--r--src/emu/disound.cpp18
-rw-r--r--src/emu/disound.h2
-rw-r--r--src/emu/emucore.h3
-rw-r--r--src/emu/sound.cpp88
-rw-r--r--src/emu/sound.h17
-rw-r--r--src/mame/audio/arcadia.cpp19
-rw-r--r--src/mame/audio/arcadia.h2
-rw-r--r--src/mame/audio/channelf.cpp17
-rw-r--r--src/mame/audio/channelf.h2
-rw-r--r--src/mame/audio/cmi01a.cpp16
-rw-r--r--src/mame/audio/cmi01a.h2
-rw-r--r--src/mame/audio/cps3.cpp16
-rw-r--r--src/mame/audio/cps3.h2
-rw-r--r--src/mame/audio/dai_snd.cpp16
-rw-r--r--src/mame/audio/dai_snd.h2
-rw-r--r--src/mame/audio/dsbz80.cpp32
-rw-r--r--src/mame/audio/dsbz80.h2
-rw-r--r--src/mame/audio/elan_eu3a05.cpp11
-rw-r--r--src/mame/audio/elan_eu3a05.h2
-rw-r--r--src/mame/audio/exidy.cpp20
-rw-r--r--src/mame/audio/exidy.h6
-rw-r--r--src/mame/audio/exidy440.cpp45
-rw-r--r--src/mame/audio/exidy440.h8
-rw-r--r--src/mame/audio/flower.cpp26
-rw-r--r--src/mame/audio/flower.h6
-rw-r--r--src/mame/audio/geebee.cpp14
-rw-r--r--src/mame/audio/geebee.h2
-rw-r--r--src/mame/audio/gomoku.cpp57
-rw-r--r--src/mame/audio/gomoku.h7
-rw-r--r--src/mame/audio/gridlee.cpp12
-rw-r--r--src/mame/audio/hyprolyb.cpp11
-rw-r--r--src/mame/audio/hyprolyb.h5
-rw-r--r--src/mame/audio/lynx.cpp40
-rw-r--r--src/mame/audio/lynx.h4
-rw-r--r--src/mame/audio/micro3d.cpp38
-rw-r--r--src/mame/audio/micro3d.h6
-rw-r--r--src/mame/audio/phoenix.cpp15
-rw-r--r--src/mame/audio/phoenix.h4
-rw-r--r--src/mame/audio/pleiads.cpp22
-rw-r--r--src/mame/audio/pleiads.h6
-rw-r--r--src/mame/audio/polepos.cpp16
-rw-r--r--src/mame/audio/polepos.h2
-rw-r--r--src/mame/audio/redbaron.cpp12
-rw-r--r--src/mame/audio/redbaron.h2
-rw-r--r--src/mame/audio/segag80r.cpp10
-rw-r--r--src/mame/audio/segausb.cpp12
-rw-r--r--src/mame/audio/segausb.h2
-rw-r--r--src/mame/audio/seibu.cpp20
-rw-r--r--src/mame/audio/seibu.h2
-rw-r--r--src/mame/audio/snk6502.cpp12
-rw-r--r--src/mame/audio/snk6502.h2
-rw-r--r--src/mame/audio/socrates.cpp10
-rw-r--r--src/mame/audio/socrates.h2
-rw-r--r--src/mame/audio/special.cpp35
-rw-r--r--src/mame/audio/special.h2
-rw-r--r--src/mame/audio/svis_snd.cpp29
-rw-r--r--src/mame/audio/svis_snd.h2
-rw-r--r--src/mame/audio/tiamc1.cpp10
-rw-r--r--src/mame/audio/tiamc1.h2
-rw-r--r--src/mame/audio/timeplt.cpp11
-rw-r--r--src/mame/audio/timeplt.h5
-rw-r--r--src/mame/audio/trackfld.cpp11
-rw-r--r--src/mame/audio/trackfld.h5
-rw-r--r--src/mame/audio/turrett.cpp19
-rw-r--r--src/mame/audio/tvc.cpp16
-rw-r--r--src/mame/audio/tvc.h2
-rw-r--r--src/mame/audio/tx1.cpp42
-rw-r--r--src/mame/audio/tx1.h10
-rw-r--r--src/mame/audio/vboy.cpp21
-rw-r--r--src/mame/audio/vboy.h2
-rw-r--r--src/mame/audio/vc4000.cpp16
-rw-r--r--src/mame/audio/vc4000.h2
-rw-r--r--src/mame/audio/warpwarp.cpp14
-rw-r--r--src/mame/audio/warpwarp.h2
-rw-r--r--src/mame/audio/wiping.cpp52
-rw-r--r--src/mame/audio/wiping.h7
-rw-r--r--src/mame/audio/wswan.cpp21
-rw-r--r--src/mame/audio/wswan.h2
-rw-r--r--src/mame/audio/xavix.cpp11
-rw-r--r--src/mame/drivers/esq1.cpp14
-rw-r--r--src/mame/drivers/istrebiteli.cpp12
-rw-r--r--src/mame/drivers/milton6805.cpp23
-rw-r--r--src/mame/drivers/ninjaw.cpp7
-rw-r--r--src/mame/drivers/pv1000.cpp19
-rw-r--r--src/mame/includes/gridlee.h2
-rw-r--r--src/mame/includes/segag80r.h2
-rw-r--r--src/mame/includes/turrett.h2
-rw-r--r--src/mame/includes/xavix.h2
-rw-r--r--src/mame/machine/mega32x.cpp11
-rw-r--r--src/mame/machine/mega32x.h2
-rw-r--r--src/mame/video/gic.cpp13
-rw-r--r--src/mame/video/gic.h2
120 files changed, 561 insertions, 856 deletions
diff --git a/src/devices/bus/a2bus/a2mcms.cpp b/src/devices/bus/a2bus/a2mcms.cpp
index f9de57897f8..1ef164aff41 100644
--- a/src/devices/bus/a2bus/a2mcms.cpp
+++ b/src/devices/bus/a2bus/a2mcms.cpp
@@ -206,7 +206,7 @@ mcms_device::mcms_device(const machine_config &mconfig, const char *tag, device_
void mcms_device::device_start()
{
m_write_irq.resolve();
- m_stream = stream_alloc_legacy(0, 2, 31250);
+ m_stream = stream_alloc(0, 2, 31250);
m_timer = timer_alloc(0, nullptr);
m_clrtimer = timer_alloc(1, nullptr);
m_enabled = false;
@@ -252,20 +252,19 @@ void mcms_device::device_timer(emu_timer &timer, device_timer_id tid, int param,
}
}
-void mcms_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *outL, *outR;
int i, v;
uint16_t wptr;
int8_t sample;
int32_t mixL, mixR;
- outL = outputs[1];
- outR = outputs[0];
+ auto &outL = outputs[1];
+ auto &outR = outputs[0];
if (m_enabled)
{
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outL.samples(); i++)
{
mixL = mixR = 0;
@@ -286,16 +285,14 @@ void mcms_device::sound_stream_update_legacy(sound_stream &stream, stream_sample
}
}
- outL[i] = (mixL * m_mastervol)>>9;
- outR[i] = (mixR * m_mastervol)>>9;
+ outL.put_int(i, mixL * m_mastervol, 32768 << 9);
+ outR.put_int(i, mixR * m_mastervol, 32768 << 9);
}
}
else
{
- for (i = 0; i < samples; i++)
- {
- outL[i] = outR[i] = 0;
- }
+ outL.fill(0);
+ outR.fill(0);
}
}
diff --git a/src/devices/bus/a2bus/a2mcms.h b/src/devices/bus/a2bus/a2mcms.h
index 11e8b332ee0..487c6ddb7a7 100644
--- a/src/devices/bus/a2bus/a2mcms.h
+++ b/src/devices/bus/a2bus/a2mcms.h
@@ -42,7 +42,7 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_stream;
diff --git a/src/devices/bus/coco/coco_ssc.cpp b/src/devices/bus/coco/coco_ssc.cpp
index 63f6e90fcc5..3677010648f 100644
--- a/src/devices/bus/coco/coco_ssc.cpp
+++ b/src/devices/bus/coco/coco_ssc.cpp
@@ -130,7 +130,7 @@ namespace
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream* m_stream;
@@ -535,25 +535,25 @@ cocossc_sac_device::cocossc_sac_device(const machine_config &mconfig, const char
void cocossc_sac_device::device_start()
{
- m_stream = stream_alloc_legacy(1, 1, machine().sample_rate());
+ m_stream = stream_alloc(1, 1, machine().sample_rate());
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void cocossc_sac_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t const *src = inputs[0];
- stream_sample_t *dst = outputs[0];
+ auto &src = inputs[0];
+ auto &dst = outputs[0];
- double n = samples;
+ double n = dst.samples();
- while (samples--)
+ for (int sampindex = 0; sampindex < n; sampindex++)
{
- m_rms[m_index] += ( (double)*src * (double)*src );
- *dst++ = (*src++);
+ m_rms[m_index] += src.get(sampindex) * src.get(sampindex);
+ dst.put(sampindex, src.get(sampindex));
}
m_rms[m_index] = m_rms[m_index] / n;
@@ -576,7 +576,7 @@ bool cocossc_sac_device::sound_activity_circuit_output()
average /= 16.0;
- if( average > 10400.0 )
+ if( average > 0.317 )
return true;
return false;
diff --git a/src/devices/bus/isa/gus.cpp b/src/devices/bus/isa/gus.cpp
index a1c3f39612e..237211047a2 100644
--- a/src/devices/bus/isa/gus.cpp
+++ b/src/devices/bus/isa/gus.cpp
@@ -243,29 +243,26 @@ void gf1_device::device_timer(emu_timer &timer, device_timer_id id, int param, v
}
}
-void gf1_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void gf1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int x,y;
+ int x;
//uint32_t count;
- stream_sample_t* outputl = outputs[0];
- stream_sample_t* outputr = outputs[1];
- memset( outputl, 0x00, samples * sizeof(*outputl) );
- memset( outputr, 0x00, samples * sizeof(*outputr) );
+ auto &outputl = outputs[0];
+ auto &outputr = outputs[1];
+
+ outputl.fill(0);
+ outputr.fill(0);
for(x=0;x<32;x++) // for each voice
{
- stream_sample_t* left = outputl;
- stream_sample_t* right = outputr;
uint16_t vol = (m_volume_table[(m_voice[x].current_vol & 0xfff0) >> 4]);
- for(y=samples-1; y>=0; y--)
+ for (int sampindex = 0; sampindex < outputl.samples(); sampindex++)
{
uint32_t current = m_voice[x].current_addr >> 9;
// TODO: implement proper panning
- (*left) += ((m_voice[x].sample) * (vol/8192.0));
- (*right) += ((m_voice[x].sample) * (vol/8192.0));
- left++;
- right++;
+ outputl.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192);
+ outputr.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192);
if((!(m_voice[x].voice_ctrl & 0x40)) && (m_voice[x].current_addr >= m_voice[x].end_addr) && !m_voice[x].rollover && !(m_voice[x].voice_ctrl & 0x01))
{
if(m_voice[x].vol_ramp_ctrl & 0x04)
@@ -403,7 +400,7 @@ void gf1_device::device_start()
m_wave_ram.resize(1024*1024);
memset(&m_wave_ram[0], 0, 1024*1024);
- m_stream = stream_alloc_legacy(0,2,clock() / (14 * 16));
+ m_stream = stream_alloc(0,2,clock() / (14 * 16));
// init timers
m_timer1 = timer_alloc(ADLIB_TIMER1);
diff --git a/src/devices/bus/isa/gus.h b/src/devices/bus/isa/gus.h
index 3f637bee84d..be8dbbdbe2d 100644
--- a/src/devices/bus/isa/gus.h
+++ b/src/devices/bus/isa/gus.h
@@ -123,7 +123,7 @@ public:
// optional information overrides
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
protected:
// voice-specific registers
diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp
index c6e20ba66dd..38f5fcfb059 100644
--- a/src/devices/imagedev/cassette.cpp
+++ b/src/devices/imagedev/cassette.cpp
@@ -236,7 +236,7 @@ void cassette_image_device::device_start()
m_state = m_default_state;
m_value = 0;
- stream_alloc_legacy(0, (m_stereo? 2:1), machine().sample_rate());
+ stream_alloc(0, m_stereo? 2:1, machine().sample_rate());
}
image_init_result cassette_image_device::call_create(int format_type, util::option_resolution *format_options)
@@ -404,37 +404,29 @@ std::string cassette_image_device::call_display()
// Cassette sound
//-------------------------------------------------
-void cassette_image_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void cassette_image_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *left_buffer = outputs[0];
- stream_sample_t *right_buffer = nullptr;
-
- if (m_stereo)
- right_buffer = outputs[1];
-
cassette_state state = get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER);
if (exists() && (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)))
{
cassette_image *cassette = get_image();
double time_index = get_position();
- double duration = ((double) samples) / machine().sample_rate();
+ double duration = ((double) outputs[0].samples()) / outputs[0].sample_rate();
- cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
- if (m_stereo)
- cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT);
+ if (m_samples.size() < outputs[0].samples())
+ m_samples.resize(outputs[0].samples());
- for (int i = samples - 1; i >= 0; i--)
+ for (int ch = 0; ch < outputs.size(); ch++)
{
- left_buffer[i] = ((int16_t *) left_buffer)[i];
- if (m_stereo)
- right_buffer[i] = ((int16_t *) right_buffer)[i];
+ cassette_get_samples(cassette, 0, time_index, duration, outputs[0].samples(), 2, &m_samples[0], CASSETTE_WAVEFORM_16BIT);
+ for (int sampindex = 0; sampindex < outputs[ch].samples(); sampindex++)
+ outputs[ch].put_int(sampindex, m_samples[sampindex], 32768);
}
}
else
{
- memset(left_buffer, 0, sizeof(*left_buffer) * samples);
- if (m_stereo)
- memset(right_buffer, 0, sizeof(*right_buffer) * samples);
+ for (int ch = 0; ch < outputs.size(); ch++)
+ outputs[ch].fill(0);
}
}
diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h
index a661e8312a8..ae3af3c6429 100644
--- a/src/devices/imagedev/cassette.h
+++ b/src/devices/imagedev/cassette.h
@@ -102,7 +102,7 @@ public:
void seek(double time, int origin);
// sound stream update overrides
- void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
device_sound_interface& set_stereo() { m_stereo = true; return *this; }
protected:
@@ -133,6 +133,7 @@ private:
image_init_result internal_load(bool is_create);
bool m_stereo;
+ std::vector<s16> m_samples;
};
// device type definition
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp
index 3dd96644f1a..f39be79c761 100644
--- a/src/devices/imagedev/floppy.cpp
+++ b/src/devices/imagedev/floppy.cpp
@@ -1248,7 +1248,7 @@ void floppy_sound_device::device_start()
// If we don't have all samples, don't allocate a stream or access sample data.
if (m_loaded)
{
- m_sound = stream_alloc_legacy(0, 1, clock()); // per-floppy stream
+ m_sound = stream_alloc(0, 1, clock()); // per-floppy stream
}
register_for_save_states();
}
@@ -1369,21 +1369,21 @@ void floppy_sound_device::step(int zone)
}
//-------------------------------------------------
-// sound_stream_update_legacy - update the sound stream
+// sound_stream_update - update the sound stream
//-------------------------------------------------
-void floppy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// We are using only one stream, unlike the parent class
// Also, there is no need for interpolation, as we only expect
// one sample rate of 44100 for all samples
int16_t out;
- stream_sample_t *samplebuffer = outputs[0];
+ auto &samplebuffer = outputs[0];
int idx = 0;
int sampleend = 0;
- while (samples-- > 0)
+ for (int sampindex = 0; sampindex < samplebuffer.samples(); sampindex++)
{
out = 0;
@@ -1477,7 +1477,7 @@ void floppy_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}
// Write to the stream buffer
- *(samplebuffer++) = out;
+ samplebuffer.put_int(sampindex, out, 32768);
}
}
diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h
index d07a12c146c..515cf28f610 100644
--- a/src/devices/imagedev/floppy.h
+++ b/src/devices/imagedev/floppy.h
@@ -294,7 +294,7 @@ protected:
private:
// device_sound_interface overrides
- void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
sound_stream* m_sound;
int m_step_base;
diff --git a/src/devices/machine/8364_paula.cpp b/src/devices/machine/8364_paula.cpp
index 1e10ca55b3e..6869ffb3395 100644
--- a/src/devices/machine/8364_paula.cpp
+++ b/src/devices/machine/8364_paula.cpp
@@ -58,7 +58,7 @@ void paula_8364_device::device_start()
}
// create the stream
- m_stream = stream_alloc_legacy(0, 4, clock() / CLOCK_DIVIDER);
+ m_stream = stream_alloc(0, 4, clock() / CLOCK_DIVIDER);
}
//-------------------------------------------------
@@ -159,10 +159,10 @@ void paula_8364_device::dma_reload(audio_channel *chan)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void paula_8364_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int channum, sampoffs = 0;
@@ -176,11 +176,11 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_
// clear the sample data to 0
for (channum = 0; channum < 4; channum++)
- memset(outputs[channum], 0, sizeof(stream_sample_t) * samples);
+ outputs[channum].fill(0);
return;
}
- samples *= CLOCK_DIVIDER;
+ int samples = outputs[0].samples() * CLOCK_DIVIDER;
// update the DMA states on each channel and reload if fresh
for (channum = 0; channum < 4; channum++)
@@ -215,7 +215,7 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_
audio_channel *chan = &m_channel[channum];
int volume = (nextvol == -1) ? chan->vol : nextvol;
int period = (nextper == -1) ? chan->per : nextper;
- stream_sample_t sample;
+ s32 sample;
int i;
// normalize the volume value
@@ -247,7 +247,7 @@ void paula_8364_device::sound_stream_update_legacy(sound_stream &stream, stream_
// fill the buffer with the sample
for (i = 0; i < ticks; i += CLOCK_DIVIDER)
- outputs[channum][(sampoffs + i) / CLOCK_DIVIDER] = sample;
+ outputs[channum].put_int((sampoffs + i) / CLOCK_DIVIDER, sample, 32768);
// account for the ticks; if we hit 0, advance
chan->curticks -= ticks;
diff --git a/src/devices/machine/8364_paula.h b/src/devices/machine/8364_paula.h
index a2ac2feab26..9fa7a6ebf38 100644
--- a/src/devices/machine/8364_paula.h
+++ b/src/devices/machine/8364_paula.h
@@ -68,7 +68,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
enum
diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp
index c376c62977c..d04d3c1201a 100644
--- a/src/devices/machine/laserdsc.cpp
+++ b/src/devices/machine/laserdsc.cpp
@@ -308,11 +308,11 @@ void laserdisc_device::device_timer(emu_timer &timer, device_timer_id id, int pa
//-------------------------------------------------
-// sound_stream_update_legacy - audio streamer for
+// sound_stream_update - audio streamer for
// laserdiscs
//-------------------------------------------------
-void laserdisc_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// compute AND values based on the squelch
int16_t leftand = (m_audiosquelch & 1) ? 0x0000 : 0xffff;
@@ -324,12 +324,12 @@ void laserdisc_device::sound_stream_update_legacy(sound_stream &stream, stream_s
samples_avail += m_audiobufsize;
// if no attached ld, just clear the buffers
- stream_sample_t *dst0 = outputs[0];
- stream_sample_t *dst1 = outputs[1];
- if (samples_avail < samples)
+ auto &dst0 = outputs[0];
+ auto &dst1 = outputs[1];
+ if (samples_avail < outputs[0].samples())
{
- memset(dst0, 0, samples * sizeof(dst0[0]));
- memset(dst1, 0, samples * sizeof(dst1[0]));
+ dst0.fill(0);
+ dst1.fill(0);
}
// otherwise, stream from our buffer
@@ -340,10 +340,11 @@ void laserdisc_device::sound_stream_update_legacy(sound_stream &stream, stream_s
int sampout = m_audiobufout;
// copy samples, clearing behind us as we go
- while (sampout != m_audiobufin && samples-- > 0)
+ int sampindex;
+ for (sampindex = 0; sampout != m_audiobufin && sampindex < outputs[0].samples(); sampindex++)
{
- *dst0++ = buffer0[sampout] & leftand;
- *dst1++ = buffer1[sampout] & rightand;
+ dst0.put_int(sampindex, buffer0[sampout] & leftand, 32768);
+ dst1.put_int(sampindex, buffer1[sampout] & rightand, 32768);
buffer0[sampout] = 0;
buffer1[sampout] = 0;
sampout++;
@@ -353,16 +354,16 @@ void laserdisc_device::sound_stream_update_legacy(sound_stream &stream, stream_s
m_audiobufout = sampout;
// clear out the rest of the buffer
- if (samples > 0)
+ if (sampindex < outputs[0].samples())
{
sampout = (m_audiobufout == 0) ? m_audiobufsize - 1 : m_audiobufout - 1;
- stream_sample_t fill0 = buffer0[sampout] & leftand;
- stream_sample_t fill1 = buffer1[sampout] & rightand;
+ s32 fill0 = buffer0[sampout] & leftand;
+ s32 fill1 = buffer1[sampout] & rightand;
- while (samples-- > 0)
+ for ( ; sampindex < outputs[0].samples(); sampindex++)
{
- *dst0++ = fill0;
- *dst1++ = fill1;
+ dst0.put_int(sampindex, fill0, 32768);
+ dst1.put_int(sampindex, fill1, 32768);
}
}
}
@@ -762,7 +763,7 @@ void laserdisc_device::init_audio()
m_audio_callback.resolve();
// allocate a stream
- m_stream = stream_alloc_legacy(0, 2, 48000);
+ m_stream = stream_alloc(0, 2, 48000);
// allocate audio buffers
m_audiomaxsamples = ((uint64_t)m_samplerate * 1000000 + m_fps_times_1million - 1) / m_fps_times_1million;
diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h
index 9e80d43df52..14594bcf7cd 100644
--- a/src/devices/machine/laserdsc.h
+++ b/src/devices/machine/laserdsc.h
@@ -220,7 +220,7 @@ protected:
virtual void device_validity_check(validity_checker &valid) const override;
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
// subclass helpers
void set_audio_squelch(bool squelchleft, bool squelchright) { m_stream->update(); m_audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); }
diff --git a/src/devices/machine/s2636.cpp b/src/devices/machine/s2636.cpp
index 4d35b829e74..8ad26690bcf 100644
--- a/src/devices/machine/s2636.cpp
+++ b/src/devices/machine/s2636.cpp
@@ -203,7 +203,7 @@ void s2636_device::device_start()
save_item(NAME(m_intreq));
save_item(NAME(m_intack));
- m_stream = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_stream = stream_alloc(0, 1, machine().sample_rate());
save_item(NAME(m_sample_cnt));
save_item(NAME(m_sound_lvl));
@@ -447,13 +447,14 @@ void s2636_device::write_intack(int state)
//-------------------------------------------------
-// sound_stream_update_legacy - generate audio output
+// sound_stream_update - generate audio output
//-------------------------------------------------
-void s2636_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+
+void s2636_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];
- while (samples--)
+ auto &buffer = outputs[0];
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
if (!m_sample_cnt)
{
@@ -469,7 +470,7 @@ void s2636_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl
}
}
- *buffer++ = m_sound_lvl ? 0x7fff : 0x0000;
+ buffer.put(sampindex, m_sound_lvl ? 1.0 : 0.0);
m_sample_cnt--;
}
}
diff --git a/src/devices/machine/s2636.h b/src/devices/machine/s2636.h
index b5e41b83499..8803c629015 100644
--- a/src/devices/machine/s2636.h
+++ b/src/devices/machine/s2636.h
@@ -58,7 +58,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
enum
diff --git a/src/devices/machine/spg2xx_audio.cpp b/src/devices/machine/spg2xx_audio.cpp
index 07d01e88be5..2441ebf17ce 100644
--- a/src/devices/machine/spg2xx_audio.cpp
+++ b/src/devices/machine/spg2xx_audio.cpp
@@ -76,7 +76,7 @@ void spg2xx_audio_device::device_start()
m_audio_beat = timer_alloc(TIMER_BEAT);
m_audio_beat->adjust(attotime::never);
- m_stream = stream_alloc_legacy(0, 2, 281250/4);
+ m_stream = stream_alloc(0, 2, 281250/4);
m_channel_debug = -1;
@@ -887,12 +887,12 @@ void spg2xx_audio_device::audio_w(offs_t offset, uint16_t data)
}
}
-void spg2xx_audio_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void spg2xx_audio_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *out_l = outputs[0];
- stream_sample_t *out_r = outputs[1];
+ auto &out_l = outputs[0];
+ auto &out_r = outputs[1];
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < out_l.samples(); i++)
{
int32_t left_total = 0;
int32_t right_total = 0;
@@ -992,8 +992,8 @@ void spg2xx_audio_device::sound_stream_update_legacy(sound_stream &stream, strea
int32_t left_final = (int16_t)((left_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7);
int32_t right_final = (int16_t)((right_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7);
- *out_l++ = (int16_t)left_final;
- *out_r++ = (int16_t)right_final;
+ out_l.put_int(i, int16_t(left_final), 32768);
+ out_r.put_int(i, int16_t(right_final), 32768);
}
}
diff --git a/src/devices/machine/spg2xx_audio.h b/src/devices/machine/spg2xx_audio.h
index 59d7635198d..588d49e7895 100644
--- a/src/devices/machine/spg2xx_audio.h
+++ b/src/devices/machine/spg2xx_audio.h
@@ -33,7 +33,7 @@ public:
protected:
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void audio_beat_tick();
void audio_rampdown_tick(const uint32_t channel);
diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp
index e0fab62505b..91d0fdc46b9 100644
--- a/src/devices/sound/astrocde.cpp
+++ b/src/devices/sound/astrocde.cpp
@@ -146,7 +146,7 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<
constexpr stream_buffer::sample_t sample_scale = 1.0f / 60.0f;
for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time)
{
- stream_sample_t cursample = 0;
+ s32 cursample = 0;
/* compute the number of cycles until the next master oscillator reset */
/* or until the next noise boundary */
diff --git a/src/devices/sound/dac76.cpp b/src/devices/sound/dac76.cpp
index bbeb5728577..1c73d7b02c1 100644
--- a/src/devices/sound/dac76.cpp
+++ b/src/devices/sound/dac76.cpp
@@ -79,7 +79,7 @@ void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_st
{
// get current output level
int step_size = (2 << m_chord);
- stream_sample_t vout = m_level[m_chord] + m_step * step_size;
+ s32 vout = m_level[m_chord] + m_step * step_size;
// apply sign bit
vout *= (m_sb ? +1 : -1);
diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp
index 1d5647e45cd..7cec35b77fe 100644
--- a/src/devices/sound/discrete.cpp
+++ b/src/devices/sound/discrete.cpp
@@ -1026,7 +1026,7 @@ void discrete_sound_device::device_reset()
// discrete_device_process - process a number of
// samples.
//
-// input / output buffers are stream_sample_t
+// input / output buffers are s32
// to not to have to convert the buffers.
// a "discrete cpu" device will pass nullptr here
//-------------------------------------------------
diff --git a/src/devices/sound/es5503.h b/src/devices/sound/es5503.h
index 2d301f5c05e..2fd316aad8e 100644
--- a/src/devices/sound/es5503.h
+++ b/src/devices/sound/es5503.h
@@ -36,7 +36,6 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) override;
// device_sound_interface overrides
- //virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
// device_rom_interface overrides
diff --git a/src/devices/sound/fm.h b/src/devices/sound/fm.h
index 32f768a824b..45381d7dda9 100644
--- a/src/devices/sound/fm.h
+++ b/src/devices/sound/fm.h
@@ -50,7 +50,7 @@ template <typename X> constexpr TIME_TYPE MULTIPLY_TIME_BY_INT(TIME_TYPE const &
#endif
-typedef stream_sample_t FMSAMPLE;
+typedef s32 FMSAMPLE;
/*
#if (FM_SAMPLE_BITS==16)
typedef int16_t FMSAMPLE;
diff --git a/src/devices/sound/fmopl.h b/src/devices/sound/fmopl.h
index b70c46f93e3..bb484b0e41b 100644
--- a/src/devices/sound/fmopl.h
+++ b/src/devices/sound/fmopl.h
@@ -16,7 +16,7 @@
/* select output bits size of output : 8 or 16 */
#define OPL_SAMPLE_BITS 16
-typedef stream_sample_t OPLSAMPLE;
+typedef s32 OPLSAMPLE;
/*
#if (OPL_SAMPLE_BITS==16)
typedef int16_t OPLSAMPLE;
diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp
index 80e4aa9cd09..868bcb70bc4 100644
--- a/src/devices/sound/ics2115.cpp
+++ b/src/devices/sound/ics2115.cpp
@@ -443,7 +443,7 @@ void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_
/*
#ifdef ICS2115_DEBUG
u32 curaddr = ((voice.osc.saddr << 20) & 0xffffff) | (voice.osc.acc >> 12);
- stream_sample_t sample = get_sample(voice);
+ s32 sample = get_sample(voice);
logerror("[%06x=%04x]", curaddr, (s16)sample);
#endif
*/
diff --git a/src/devices/sound/k053260.cpp b/src/devices/sound/k053260.cpp
index 0032d834df6..7337b0c8b91 100644
--- a/src/devices/sound/k053260.cpp
+++ b/src/devices/sound/k053260.cpp
@@ -311,7 +311,7 @@ void k053260_device::sound_stream_update(sound_stream &stream, std::vector<read_
{
for ( int j = 0; j < outputs[0].samples(); j++ )
{
- stream_sample_t buffer[2] = {0, 0};
+ s32 buffer[2] = {0, 0};
for (auto & voice : m_voice)
{
@@ -435,7 +435,7 @@ void k053260_device::KDSC_Voice::key_off()
m_playing = false;
}
-void k053260_device::KDSC_Voice::play(stream_sample_t *outputs)
+void k053260_device::KDSC_Voice::play(s32 *outputs)
{
m_counter += CLOCKS_PER_SAMPLE;
diff --git a/src/devices/sound/k053260.h b/src/devices/sound/k053260.h
index a50b8b9196e..ad14244ceb9 100644
--- a/src/devices/sound/k053260.h
+++ b/src/devices/sound/k053260.h
@@ -79,7 +79,7 @@ private:
inline void update_pan_volume();
inline void key_on();
inline void key_off();
- inline void play(stream_sample_t *outputs);
+ inline void play(s32 *outputs);
inline bool playing() { return m_playing; }
inline u8 read_rom(bool side_effects);
diff --git a/src/devices/sound/s_dsp.cpp b/src/devices/sound/s_dsp.cpp
index 52d255dbfc6..98cd204b503 100644
--- a/src/devices/sound/s_dsp.cpp
+++ b/src/devices/sound/s_dsp.cpp
@@ -1074,7 +1074,7 @@ void s_dsp_device::sound_stream_update(sound_stream &stream, std::vector<read_st
dsp_update(mix);
/* Update the buffers */
- outputs[0].put_int(i, (stream_sample_t)mix[0], 32768);
- outputs[1].put_int(i, (stream_sample_t)mix[1], 32768);
+ outputs[0].put_int(i, (s32)mix[0], 32768);
+ outputs[1].put_int(i, (s32)mix[1], 32768);
}
}
diff --git a/src/devices/sound/ymf262.h b/src/devices/sound/ymf262.h
index 3c02e0da16c..fe131169fcf 100644
--- a/src/devices/sound/ymf262.h
+++ b/src/devices/sound/ymf262.h
@@ -8,7 +8,7 @@
/* select number of output bits: 8 or 16 */
#define OPL3_SAMPLE_BITS 16
-typedef stream_sample_t OPL3SAMPLE;
+typedef s32 OPL3SAMPLE;
/*
#if (OPL3_SAMPLE_BITS==16)
typedef int16_t OPL3SAMPLE;
diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp
index d2c063ff205..10d16150b76 100644
--- a/src/emu/disound.cpp
+++ b/src/emu/disound.cpp
@@ -66,15 +66,10 @@ device_sound_interface &device_sound_interface::add_route(u32 output, device_t &
//-------------------------------------------------
-// stream_alloc_legacy - allocate a stream implicitly
+// stream_alloc - allocate a stream implicitly
// associated with this device
//-------------------------------------------------
-sound_stream *device_sound_interface::stream_alloc_legacy(int inputs, int outputs, int sample_rate)
-{
- return device().machine().sound().stream_alloc_legacy(*this, inputs, outputs, sample_rate, stream_update_legacy_delegate(&device_sound_interface::sound_stream_update_legacy, this));
-}
-
sound_stream *device_sound_interface::stream_alloc(int inputs, int outputs, int sample_rate)
{
return device().machine().sound().stream_alloc(*this, inputs, outputs, sample_rate, stream_update_delegate(&device_sound_interface::sound_stream_update, this), STREAM_DEFAULT_FLAGS);
@@ -382,17 +377,6 @@ void device_sound_interface::interface_pre_reset()
//-------------------------------------------------
-// sound_stream_update_legacy - implementation
-// that should be overridden by legacy devices
-//-------------------------------------------------
-
-void device_sound_interface::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
-{
- throw emu_fatalerror("sound_stream_update_legacy called but not overridden by owning class");
-}
-
-
-//-------------------------------------------------
// sound_stream_update - default implementation
// that should be overridden
//-------------------------------------------------
diff --git a/src/emu/disound.h b/src/emu/disound.h
index db6456dfc9a..2e4546da52c 100644
--- a/src/emu/disound.h
+++ b/src/emu/disound.h
@@ -77,11 +77,9 @@ public:
device_sound_interface &reset_routes() { m_route_list.clear(); return *this; }
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples);
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
// stream creation
- sound_stream *stream_alloc_legacy(int inputs, int outputs, int sample_rate);
sound_stream *stream_alloc(int inputs, int outputs, int sample_rate);
sound_stream *stream_alloc(int inputs, int outputs, int sample_rate, sound_stream_flags flags);
diff --git a/src/emu/emucore.h b/src/emu/emucore.h
index b03612512cd..5a2446637c8 100644
--- a/src/emu/emucore.h
+++ b/src/emu/emucore.h
@@ -85,9 +85,6 @@ typedef void genf(void);
// pen_t is used to represent pixel values in bitmaps
typedef u32 pen_t;
-// stream_sample_t is used to represent a single sample in a sound stream
-typedef s32 stream_sample_t;
-
//**************************************************************************
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp
index 1c33166524f..8063db03959 100644
--- a/src/emu/sound.cpp
+++ b/src/emu/sound.cpp
@@ -578,12 +578,10 @@ sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output
m_resampling_disabled((flags & STREAM_DISABLE_INPUT_RESAMPLING) != 0),
m_sync_timer(nullptr),
m_input(inputs),
- m_input_array(inputs),
m_input_view(inputs),
m_empty_buffer(100),
m_output_base(output_base),
m_output(outputs),
- m_output_array(outputs),
m_output_view(outputs)
{
sound_assert(outputs > 0);
@@ -628,21 +626,7 @@ sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output
//-------------------------------------------------
-// sound_stream - constructor with old-style
-// callback
-//-------------------------------------------------
-
-sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_legacy_delegate callback, sound_stream_flags flags) :
- sound_stream(device, inputs, outputs, output_base, sample_rate, flags)
-{
- m_callback = std::move(callback);
- m_callback_ex = stream_update_delegate(&sound_stream::stream_update_legacy, this);
-}
-
-
-//-------------------------------------------------
-// sound_stream - constructor with new-style
-// callback
+// sound_stream - constructor
//-------------------------------------------------
sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags) :
@@ -847,7 +831,7 @@ void sound_stream::apply_sample_rate_changes(u32 updatenum, u32 downstream_rate)
#if (SOUND_DEBUG)
void sound_stream::print_graph_recursive(int indent, int index)
{
- osd_printf_info("%c %*s%s Ch.%d @ %d\n", m_callback.isnull() ? ' ' : '!', indent, "", name().c_str(), index + m_output_base, sample_rate());
+ osd_printf_info("%*s%s Ch.%d @ %d\n", indent, "", name().c_str(), index + m_output_base, sample_rate());
for (int index = 0; index < m_input.size(); index++)
if (m_input[index].valid())
{
@@ -924,57 +908,6 @@ void sound_stream::sync_update(void *, s32)
//-------------------------------------------------
-// stream_update_legacy - new-style callback which
-// forwards on to the old-style traditional
-// callback, converting to/from floats
-//-------------------------------------------------
-
-void sound_stream::stream_update_legacy(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
-{
- // temporary buffer to hold stream_sample_t inputs and outputs
- stream_sample_t temp_buffer[1024];
- int chunksize = ARRAY_LENGTH(temp_buffer) / (inputs.size() + outputs.size());
- int chunknum = 0;
-
- // create the arrays to pass to the callback
- stream_sample_t **inputptr = m_input.empty() ? nullptr : &m_input_array[0];
- stream_sample_t **outputptr = &m_output_array[0];
- for (unsigned int inputnum = 0; inputnum < inputs.size(); inputnum++)
- inputptr[inputnum] = &temp_buffer[chunksize * chunknum++];
- for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++)
- outputptr[outputnum] = &temp_buffer[chunksize * chunknum++];
-
- // loop until all chunks done
- for (int baseindex = 0; baseindex < outputs[0].samples(); baseindex += chunksize)
- {
- // determine the number of samples to process this time
- int cursamples = outputs[0].samples() - baseindex;
- if (cursamples > chunksize)
- cursamples = chunksize;
-
- // copy in the input data
- for (unsigned int inputnum = 0; inputnum < inputs.size(); inputnum++)
- {
- stream_sample_t *dest = inputptr[inputnum];
- for (int index = 0; index < cursamples; index++)
- dest[index] = stream_sample_t(inputs[inputnum].get(baseindex + index) * stream_buffer::sample_t(32768.0));
- }
-
- // run the callback
- m_callback(*this, inputptr, outputptr, cursamples);
-
- // copy out the output data
- for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++)
- {
- stream_sample_t *src = outputptr[outputnum];
- for (int index = 0; index < cursamples; index++)
- outputs[outputnum].put(baseindex + index, stream_buffer::sample_t(src[index]) * stream_buffer::sample_t(1.0 / 32768.0));
- }
- }
-}
-
-
-//-------------------------------------------------
// empty_view - return an empty view covering the
// given time period as a substitute for invalid
// inputs
@@ -1200,23 +1133,6 @@ sound_manager::~sound_manager()
//-------------------------------------------------
-// stream_alloc_legacy - allocate a new stream
-//-------------------------------------------------
-
-sound_stream *sound_manager::stream_alloc_legacy(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_legacy_delegate callback)
-{
- // determine output base
- u32 output_base = 0;
- for (auto &stream : m_stream_list)
- if (&stream->device() == &device)
- output_base += stream->output_count();
-
- m_stream_list.push_back(std::make_unique<sound_stream>(device, inputs, outputs, output_base, sample_rate, callback));
- return m_stream_list.back().get();
-}
-
-
-//-------------------------------------------------
// stream_alloc - allocate a new stream with the
// new-style callback and flags
//-------------------------------------------------
diff --git a/src/emu/sound.h b/src/emu/sound.h
index f592c0f9f3c..25944847565 100644
--- a/src/emu/sound.h
+++ b/src/emu/sound.h
@@ -576,10 +576,7 @@ private:
};
-// ======================> stream_update_legacy_delegate/stream_update_delegate
-
-// old-style callback; eventually should be deprecated
-using stream_update_legacy_delegate = delegate<void (sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)>;
+// ======================> stream_update_delegate
// new-style callback
using stream_update_delegate = delegate<void (sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)>;
@@ -614,7 +611,6 @@ class sound_stream
public:
// construction/destruction
- sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_legacy_delegate callback, sound_stream_flags flags = STREAM_DEFAULT_FLAGS);
sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags = STREAM_DEFAULT_FLAGS);
virtual ~sound_stream();
@@ -680,9 +676,6 @@ private:
// timer callback for synchronous streams
void sync_update(void *, s32);
- // new callback which wrapps calls through to the old-style callbacks
- void stream_update_legacy(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
-
// return a view of 0 data covering the given time period
read_stream_view empty_view(attotime start, attotime end);
@@ -702,7 +695,6 @@ private:
// input information
std::vector<sound_stream_input> m_input; // list of streams we directly depend upon
- std::vector<stream_sample_t *> m_input_array; // array of inputs for passing to the callback
std::vector<read_stream_view> m_input_view; // array of output views for passing to the callback
std::vector<std::unique_ptr<sound_stream>> m_resampler_list; // internal list of resamplers
stream_buffer m_empty_buffer; // empty buffer for invalid inputs
@@ -710,12 +702,10 @@ private:
// output information
u32 m_output_base; // base index of our outputs, relative to our device
std::vector<sound_stream_output> m_output; // list of streams which directly depend upon us
- std::vector<stream_sample_t *> m_output_array; // array of outputs for passing to the callback
std::vector<write_stream_view> m_output_view; // array of output views for passing to the callback
// callback information
- stream_update_legacy_delegate m_callback; // callback function
- stream_update_delegate m_callback_ex; // extended callback function
+ stream_update_delegate m_callback_ex; // extended callback function
};
@@ -774,9 +764,6 @@ public:
int sample_count() const { return m_samples_this_update; }
int unique_id() { return m_unique_id++; }
- // allocate a new stream with the old-style callback
- sound_stream *stream_alloc_legacy(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_legacy_delegate callback);
-
// allocate a new stream with a new-style callback
sound_stream *stream_alloc(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags);
diff --git a/src/mame/audio/arcadia.cpp b/src/mame/audio/arcadia.cpp
index 19adb9fac4e..46c7c9ee64f 100644
--- a/src/mame/audio/arcadia.cpp
+++ b/src/mame/audio/arcadia.cpp
@@ -59,7 +59,7 @@ arcadia_sound_device::arcadia_sound_device(const machine_config &mconfig, const
//-------------------------------------------------
void arcadia_sound_device::device_start()
{
- m_channel = stream_alloc_legacy(0, 1, UVI_PAL*OSAMP);
+ m_channel = stream_alloc(0, 1, UVI_PAL*OSAMP);
m_lfsr = LFSR_INIT;
m_tval = 1;
logerror("arcadia_sound start\n");
@@ -76,18 +76,18 @@ void arcadia_sound_device::device_reset()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void arcadia_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void arcadia_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int i;
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
- for (i = 0; i < samples; i++, buffer++)
+ for (i = 0; i < buffer.samples(); i++)
{
- *buffer = 0;
+ s32 result = 0;
//if minimal pitch ?
if (m_reg[1]){
@@ -97,17 +97,17 @@ void arcadia_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
//tone only
case 1:
- *buffer = m_volume * m_tval;
+ result = m_volume * m_tval;
break;
//noise only
case 2:
- *buffer = m_volume * m_nval;
+ result = m_volume * m_nval;
break;
//tone AND noise (bitwise and)
case 3:
- *buffer = m_volume * (m_tval & m_nval);
+ result = m_volume * (m_tval & m_nval);
break;
}
@@ -132,6 +132,7 @@ void arcadia_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
m_pos = 0;
}
}
+ buffer.put_int(i, result, 32768);
}
}
diff --git a/src/mame/audio/arcadia.h b/src/mame/audio/arcadia.h
index de67b71705d..6eb25f9e970 100644
--- a/src/mame/audio/arcadia.h
+++ b/src/mame/audio/arcadia.h
@@ -21,7 +21,7 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
sound_stream *m_channel;
uint8_t m_reg[3];
diff --git a/src/mame/audio/channelf.cpp b/src/mame/audio/channelf.cpp
index 5003f28ae3a..ec4971d35df 100644
--- a/src/mame/audio/channelf.cpp
+++ b/src/mame/audio/channelf.cpp
@@ -30,7 +30,7 @@ void channelf_sound_device::device_start()
{
int rate;
- m_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_channel = stream_alloc(0, 1, machine().sample_rate());
rate = machine().sample_rate();
/*
@@ -67,19 +67,18 @@ void channelf_sound_device::device_start()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void channelf_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void channelf_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
uint32_t mask = 0, target = 0;
- stream_sample_t *buffer = outputs[0];
- stream_sample_t *sample = buffer;
+ auto &buffer = outputs[0];
switch( m_sound_mode )
{
case 0: /* sound off */
- memset(buffer,0,sizeof(*buffer)*samples);
+ buffer.fill(0);
return;
case 1: /* high tone (2V) - 1000Hz */
@@ -96,12 +95,12 @@ void channelf_sound_device::sound_stream_update_legacy(sound_stream &stream, str
break;
}
- while (samples-- > 0)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
if ((m_forced_ontime > 0) || ((m_sample_counter & mask) == target)) // change made for improved sound
- *sample++ = m_envelope;
+ buffer.put_int(sampindex, m_envelope, 32768);
else
- *sample++ = 0;
+ buffer.put(sampindex, 0);
m_sample_counter += m_incr;
m_envelope *= m_decay_mult;
if (m_forced_ontime > 0) // added for improved sound
diff --git a/src/mame/audio/channelf.h b/src/mame/audio/channelf.h
index 36c98aa47ed..ce1231c3951 100644
--- a/src/mame/audio/channelf.h
+++ b/src/mame/audio/channelf.h
@@ -20,7 +20,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
// internal state
sound_stream *m_channel;
diff --git a/src/mame/audio/cmi01a.cpp b/src/mame/audio/cmi01a.cpp
index dbb180c2247..f99eccb71c9 100644
--- a/src/mame/audio/cmi01a.cpp
+++ b/src/mame/audio/cmi01a.cpp
@@ -132,7 +132,7 @@ void cmi01a_device::device_add_mconfig(machine_config &config)
}
-void cmi01a_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void cmi01a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
if (m_run)
{
@@ -140,23 +140,21 @@ void cmi01a_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
int addr = m_segment_cnt;
uint8_t *wave_ptr = &m_wave_ram[m_segment_cnt & 0x3fff];
- stream_sample_t *buf = outputs[0];
+ auto &buf = outputs[0];
- while (samples--)
+ for (int sampindex = 0; sampindex < buf.samples(); sampindex++)
{
const uint8_t sample8 = wave_ptr[addr++ & 0x3fff];
- int32_t sample = (int32_t)(int8_t)(sample8 ^ 0x80) * m_env * m_vol_latch;
+ s32 sample = (int32_t)(int8_t)(sample8 ^ 0x80) * m_env * m_vol_latch;
if (m_channel == 5) printf("%08x:%02x:%02x:%02x", (uint32_t)sample, sample8, m_env, m_vol_latch);
- *buf++ = (int16_t)(sample >> 8);
+ buf.put_int(sampindex, (int16_t)(sample >> 8), 32768);
}
if (m_channel == 5) printf("\n");
m_segment_cnt = (m_segment_cnt & ~mask) | addr;
}
else
- {
- memset(outputs[0], 0, samples * sizeof(stream_sample_t));
- }
+ outputs[0].fill(0);
}
void cmi01a_device::device_resolve_objects()
@@ -175,7 +173,7 @@ void cmi01a_device::device_start()
m_zx_timer->adjust(attotime::never);
m_eosi_timer->adjust(attotime::never);
- m_stream = stream_alloc_legacy(0, 1, 44100);
+ m_stream = stream_alloc(0, 1, 44100);
m_ptm->set_external_clocks(clock() / 8, clock() / 4, clock() / 4);
diff --git a/src/mame/audio/cmi01a.h b/src/mame/audio/cmi01a.h
index 7e5da0b56a8..743c50e5829 100644
--- a/src/mame/audio/cmi01a.h
+++ b/src/mame/audio/cmi01a.h
@@ -34,7 +34,7 @@ public:
void write(offs_t offset, uint8_t data);
uint8_t read(offs_t offset);
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
protected:
virtual void device_resolve_objects() override;
diff --git a/src/mame/audio/cps3.cpp b/src/mame/audio/cps3.cpp
index aa7eb8340f0..bbefabf4d50 100644
--- a/src/mame/audio/cps3.cpp
+++ b/src/mame/audio/cps3.cpp
@@ -39,7 +39,7 @@ cps3_sound_device::cps3_sound_device(const machine_config &mconfig, const char *
void cps3_sound_device::device_start()
{
/* Allocate the stream */
- m_stream = stream_alloc_legacy(0, 2, clock() / 384);
+ m_stream = stream_alloc(0, 2, clock() / 384);
save_item(NAME(m_key));
for (int i = 0; i < 16; i++)
@@ -52,14 +52,14 @@ void cps3_sound_device::device_start()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void cps3_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void cps3_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
/* Clear the buffers */
- memset(outputs[0], 0, samples*sizeof(*outputs[0]));
- memset(outputs[1], 0, samples*sizeof(*outputs[1]));
+ outputs[0].fill(0);
+ outputs[1].fill(0);
for (int i = 0; i < 16; i ++)
{
@@ -103,7 +103,7 @@ void cps3_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_
loop -= 0x400000;
/* Go through the buffer and add voice contributions */
- for (int j = 0; j < samples; j++)
+ for (int j = 0; j < outputs[0].samples(); j++)
{
int32_t sample;
@@ -127,8 +127,8 @@ void cps3_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_
sample = m_base[BYTE4_XOR_LE(start + pos)];
frac += step;
- outputs[0][j] += ((sample * vol_l) >> 8);
- outputs[1][j] += ((sample * vol_r) >> 8);
+ outputs[0].add_int(j, sample * vol_l, 32768 << 8);
+ outputs[1].add_int(j, sample * vol_r, 32768 << 8);
}
vptr->pos = pos;
diff --git a/src/mame/audio/cps3.h b/src/mame/audio/cps3.h
index 4e3fe471c8d..101fa8903ce 100644
--- a/src/mame/audio/cps3.h
+++ b/src/mame/audio/cps3.h
@@ -46,7 +46,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_stream;
diff --git a/src/mame/audio/dai_snd.cpp b/src/mame/audio/dai_snd.cpp
index 37004da5644..52334c699f8 100644
--- a/src/mame/audio/dai_snd.cpp
+++ b/src/mame/audio/dai_snd.cpp
@@ -33,7 +33,7 @@ dai_sound_device::dai_sound_device(const machine_config &mconfig, const char *ta
void dai_sound_device::device_start()
{
- m_mixer_channel = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_mixer_channel = stream_alloc(0, 2, machine().sample_rate());
}
//-------------------------------------------------
@@ -115,27 +115,27 @@ WRITE_LINE_MEMBER(dai_sound_device::set_input_ch2)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void dai_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void dai_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *sample_left = outputs[0];
- stream_sample_t *sample_right = outputs[1];
+ auto &sample_left = outputs[0];
+ auto &sample_right = outputs[1];
int16_t channel_0_signal = m_dai_input[0] ? s_osc_volume_table[m_osc_volume[0]] : -s_osc_volume_table[m_osc_volume[0]];
int16_t channel_1_signal = m_dai_input[1] ? s_osc_volume_table[m_osc_volume[1]] : -s_osc_volume_table[m_osc_volume[1]];
int16_t channel_2_signal = m_dai_input[2] ? s_osc_volume_table[m_osc_volume[2]] : -s_osc_volume_table[m_osc_volume[2]];
- while (samples--)
+ for (int sampindex = 0; sampindex < sample_left.samples(); sampindex++)
{
int16_t noise = machine().rand()&0x01 ? s_noise_volume_table[m_noise_volume] : -s_noise_volume_table[m_noise_volume];
/* channel 0 + channel 1 + noise */
- *sample_left++ = channel_0_signal + channel_1_signal + noise;
+ sample_left.put_int(sampindex, channel_0_signal + channel_1_signal + noise, 32768);
/* channel 1 + channel 2 + noise */
- *sample_right++ = channel_1_signal + channel_2_signal + noise;
+ sample_right.put_int(sampindex, channel_1_signal + channel_2_signal + noise, 32768);
}
}
diff --git a/src/mame/audio/dai_snd.h b/src/mame/audio/dai_snd.h
index cea0e1c6c71..f34bed0199d 100644
--- a/src/mame/audio/dai_snd.h
+++ b/src/mame/audio/dai_snd.h
@@ -27,7 +27,7 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream * m_mixer_channel;
diff --git a/src/mame/audio/dsbz80.cpp b/src/mame/audio/dsbz80.cpp
index 7643face54b..ad7f25bbfcd 100644
--- a/src/mame/audio/dsbz80.cpp
+++ b/src/mame/audio/dsbz80.cpp
@@ -85,7 +85,7 @@ void dsbz80_device::device_start()
m_rxd_handler.resolve_safe();
uint8_t *rom_base = machine().root_device().memregion("mpeg")->base();
decoder = new mpeg_audio(rom_base, mpeg_audio::L2, false, 0);
- stream_alloc_legacy(0, 2, 32000);
+ stream_alloc(0, 2, 32000);
}
//-------------------------------------------------
@@ -232,11 +232,13 @@ void dsbz80_device::mpeg_stereo_w(uint8_t data)
mp_pan = data & 3; // 0 = stereo, 1 = left on both channels, 2 = right on both channels
}
-void dsbz80_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void dsbz80_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *out_l = outputs[0];
- stream_sample_t *out_r = outputs[1];
+ auto &out_l = outputs[0];
+ auto &out_r = outputs[1];
+ int samples = out_l.samples();
+ int sampindex = 0;
for(;;)
{
while(samples && audio_pos < audio_avail)
@@ -244,18 +246,21 @@ void dsbz80_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
switch (mp_pan)
{
case 0: // stereo
- *out_l++ = audio_buf[audio_pos*2];
- *out_r++ = audio_buf[audio_pos*2+1];
+ out_l.put_int(sampindex, audio_buf[audio_pos*2], 32768);
+ out_r.put_int(sampindex, audio_buf[audio_pos*2+1], 32768);
+ sampindex++;
break;
case 1: // left only
- *out_l++ = audio_buf[audio_pos*2];
- *out_r++ = audio_buf[audio_pos*2];
+ out_l.put_int(sampindex, audio_buf[audio_pos*2], 32768);
+ out_r.put_int(sampindex, audio_buf[audio_pos*2], 32768);
+ sampindex++;
break;
case 2: // right only
- *out_l++ = audio_buf[audio_pos*2+1];
- *out_r++ = audio_buf[audio_pos*2+1];
+ out_l.put_int(sampindex, audio_buf[audio_pos*2+1], 32768);
+ out_r.put_int(sampindex, audio_buf[audio_pos*2+1], 32768);
+ sampindex++;
break;
}
audio_pos++;
@@ -269,11 +274,8 @@ void dsbz80_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
if(mp_state == 0)
{
- for(int i=0; i != samples; i++)
- {
- *out_l++ = 0;
- *out_r++ = 0;
- }
+ out_l.fill(0, sampindex);
+ out_r.fill(0, sampindex);
break;
}
diff --git a/src/mame/audio/dsbz80.h b/src/mame/audio/dsbz80.h
index 92e0c4f3f2f..6f135454524 100644
--- a/src/mame/audio/dsbz80.h
+++ b/src/mame/audio/dsbz80.h
@@ -37,7 +37,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
mpeg_audio *decoder;
diff --git a/src/mame/audio/elan_eu3a05.cpp b/src/mame/audio/elan_eu3a05.cpp
index 39ab90a08fb..1922ee3b1da 100644
--- a/src/mame/audio/elan_eu3a05.cpp
+++ b/src/mame/audio/elan_eu3a05.cpp
@@ -54,7 +54,7 @@ void elan_eu3a05_sound_device::map(address_map &map)
void elan_eu3a05_sound_device::device_start()
{
m_space_read_cb.resolve_safe(0);
- m_stream = stream_alloc_legacy(0, 1, 8000);
+ m_stream = stream_alloc(0, 1, 8000);
m_sound_end_cb.resolve_all_safe();
@@ -92,18 +92,19 @@ void elan_eu3a05_sound_device::device_reset()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void elan_eu3a05_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// reset the output stream
- memset(outputs[0], 0, samples * sizeof(*outputs[0]));
+ outputs[0].fill(0);
int volume = m_volumes[0] | (m_volumes[1] << 8);
int outpos = 0;
// loop while we still have samples to generate
+ int samples = outputs[0].samples();
while (samples-- != 0)
{
int total = 0;
@@ -142,7 +143,7 @@ void elan_eu3a05_sound_device::sound_stream_update_legacy(sound_stream &stream,
//LOGMASKED( LOG_AUDIO, "m_isstopped %02x channel %d is NOT active %08x %06x\n", m_isstopped, channel, m_sound_byte_address[channel], m_sound_current_nib_pos[channel]);
}
}
- outputs[0][outpos] = total / 6;
+ outputs[0].put_int(outpos, total, 32768 * 6);
outpos++;
}
}
diff --git a/src/mame/audio/elan_eu3a05.h b/src/mame/audio/elan_eu3a05.h
index c9ef2e83ab3..692d685cf64 100644
--- a/src/mame/audio/elan_eu3a05.h
+++ b/src/mame/audio/elan_eu3a05.h
@@ -30,7 +30,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
virtual space_config_vector memory_space_config() const override;
const address_space_config m_space_config;
diff --git a/src/mame/audio/exidy.cpp b/src/mame/audio/exidy.cpp
index 8220c3e1af7..3f5b6559f2e 100644
--- a/src/mame/audio/exidy.cpp
+++ b/src/mame/audio/exidy.cpp
@@ -180,7 +180,7 @@ void exidy_sound_device::common_sh_start()
m_sh6840_clocks_per_sample = (int)(SH6840_CLOCK.dvalue() / (double)sample_rate * (double)(1 << 24));
/* allocate the stream */
- m_stream = stream_alloc_legacy(0, 1, sample_rate);
+ m_stream = stream_alloc(0, 1, sample_rate);
sh6840_register_state_globals();
}
@@ -239,23 +239,23 @@ void exidy_sound_device::device_reset()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void exidy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void exidy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
sh6840_timer_channel *sh6840_timer = m_sh6840_timer;
/* hack to skip the expensive lfsr noise generation unless at least one of the 3 channels actually depends on it being generated */
int noisy = ((sh6840_timer[0].cr & sh6840_timer[1].cr & sh6840_timer[2].cr & 0x02) == 0);
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
/* loop over samples */
- while (samples--)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
sh6840_timer_channel *t;
int clocks;
- stream_sample_t sample = 0;
+ s32 sample = 0;
/* determine how many 6840 clocks this sample */
m_sh6840_clock_count += m_sh6840_clocks_per_sample;
@@ -310,19 +310,19 @@ void exidy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream
sample += generate_music_sample();
/* stash */
- *buffer++ = sample;
+ buffer.put_int(sampindex, sample, 32768);
}
}
-stream_sample_t exidy_sound_device::generate_music_sample()
+s32 exidy_sound_device::generate_music_sample()
{
return 0;
}
-stream_sample_t exidy_sh8253_sound_device::generate_music_sample()
+s32 exidy_sh8253_sound_device::generate_music_sample()
{
sh8253_timer_channel *c;
- stream_sample_t sample = 0;
+ s32 sample = 0;
/* music channel 0 */
c = &m_sh8253_timer[0];
diff --git a/src/mame/audio/exidy.h b/src/mame/audio/exidy.h
index 86ed7b145cd..c619cd1975d 100644
--- a/src/mame/audio/exidy.h
+++ b/src/mame/audio/exidy.h
@@ -54,8 +54,8 @@ protected:
void sh6840_register_state_globals();
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
- virtual stream_sample_t generate_music_sample();
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
+ virtual s32 generate_music_sample();
static inline void sh6840_apply_clock(sh6840_timer_channel *t, int clocks);
@@ -102,7 +102,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
- virtual stream_sample_t generate_music_sample() override;
+ virtual s32 generate_music_sample() override;
void r6532_porta_w(uint8_t data);
uint8_t r6532_porta_r();
diff --git a/src/mame/audio/exidy440.cpp b/src/mame/audio/exidy440.cpp
index a4ca2d10339..a5a40cae628 100644
--- a/src/mame/audio/exidy440.cpp
+++ b/src/mame/audio/exidy440.cpp
@@ -74,8 +74,6 @@ exidy440_sound_device::exidy440_sound_device(const machine_config &mconfig, cons
m_samples(*this, "samples"),
m_sound_command(0),
m_sound_command_ack(0),
- m_mixer_buffer_left(nullptr),
- m_mixer_buffer_right(nullptr),
m_sound_cache(nullptr),
m_sound_cache_end(nullptr),
m_sound_cache_max(nullptr),
@@ -146,7 +144,7 @@ void exidy440_sound_device::device_start()
m_channel_frequency[3] = clock()/2;
/* get stream channels */
- m_stream = stream_alloc_legacy(0, 2, clock());
+ m_stream = stream_alloc(0, 2, clock());
/* allocate the sample cache */
length = m_samples.bytes() * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry);
@@ -157,8 +155,8 @@ void exidy440_sound_device::device_start()
reset_sound_cache();
/* allocate the mixer buffer */
- m_mixer_buffer_left = make_unique_clear<int32_t[]>(clock());
- m_mixer_buffer_right = make_unique_clear<int32_t[]>(clock());
+ m_mixer_buffer_left.resize(clock()/50);
+ m_mixer_buffer_right.resize(clock()/50);
if (SOUND_LOG)
m_debuglog = fopen("sound.log", "w");
@@ -224,24 +222,15 @@ void exidy440_sound_device::add_and_scale_samples(int ch, int32_t *dest, int sam
*
*************************************/
-void exidy440_sound_device::mix_to_16(int length, stream_sample_t *dest_left, stream_sample_t *dest_right)
+void exidy440_sound_device::mix_to_16(write_stream_view &dest_left, write_stream_view &dest_right)
{
- int32_t *mixer_left = m_mixer_buffer_left.get();
- int32_t *mixer_right = m_mixer_buffer_right.get();
- int i, clippers = 0;
+ int32_t *mixer_left = &m_mixer_buffer_left[0];
+ int32_t *mixer_right = &m_mixer_buffer_right[0];
- for (i = 0; i < length; i++)
+ for (int i = 0; i < dest_left.samples(); i++)
{
- int32_t sample_left = *mixer_left++;
- int32_t sample_right = *mixer_right++;
-
- if (sample_left < -32768) { sample_left = -32768; clippers++; }
- else if (sample_left > 32767) { sample_left = 32767; clippers++; }
- if (sample_right < -32768) { sample_right = -32768; clippers++; }
- else if (sample_right > 32767) { sample_right = 32767; clippers++; }
-
- *dest_left++ = sample_left;
- *dest_right++ = sample_right;
+ dest_left.put_int_clamp(i, *mixer_left++, 32768);
+ dest_right.put_int_clamp(i, *mixer_right++, 32768);
}
}
@@ -836,22 +825,22 @@ void exidy440_sound_device::sound_banks_w(offs_t offset, uint8_t data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void exidy440_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void exidy440_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int ch;
/* reset the mixer buffers */
- memset(m_mixer_buffer_left.get(), 0, samples * sizeof(int32_t));
- memset(m_mixer_buffer_right.get(), 0, samples * sizeof(int32_t));
+ std::fill_n(&m_mixer_buffer_left[0], outputs[0].samples(), 0);
+ std::fill_n(&m_mixer_buffer_right[0], outputs[0].samples(), 0);
/* loop over channels */
for (ch = 0; ch < 4; ch++)
{
sound_channel_data *channel = &m_sound_channel[ch];
- int length, volume, left = samples;
+ int length, volume, left = outputs[0].samples();
int effective_offset;
/* if we're not active, bail */
@@ -864,12 +853,12 @@ void exidy440_sound_device::sound_stream_update_legacy(sound_stream &stream, str
/* get a pointer to the sample data and copy to the left */
volume = m_sound_volume[2 * ch + 0];
if (volume)
- add_and_scale_samples(ch, m_mixer_buffer_left.get(), length, volume);
+ add_and_scale_samples(ch, &m_mixer_buffer_left[0], length, volume);
/* get a pointer to the sample data and copy to the left */
volume = m_sound_volume[2 * ch + 1];
if (volume)
- add_and_scale_samples(ch, m_mixer_buffer_right.get(), length, volume);
+ add_and_scale_samples(ch, &m_mixer_buffer_right[0], length, volume);
/* update our counters */
channel->offset += length;
@@ -889,5 +878,5 @@ void exidy440_sound_device::sound_stream_update_legacy(sound_stream &stream, str
}
/* all done, time to mix it */
- mix_to_16(samples, outputs[0], outputs[1]);
+ mix_to_16(outputs[0], outputs[1]);
}
diff --git a/src/mame/audio/exidy440.h b/src/mame/audio/exidy440.h
index 9f8861bdfe3..e3920be90a2 100644
--- a/src/mame/audio/exidy440.h
+++ b/src/mame/audio/exidy440.h
@@ -29,7 +29,7 @@ protected:
virtual void device_stop() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
void exidy440_audio_map(address_map &map);
@@ -76,8 +76,8 @@ private:
uint8_t m_sound_banks[4];
//uint8_t m_m6844_data[0x20];
uint8_t m_sound_volume[0x10];
- std::unique_ptr<int32_t[]> m_mixer_buffer_left;
- std::unique_ptr<int32_t[]> m_mixer_buffer_right;
+ std::vector<int32_t> m_mixer_buffer_left;
+ std::vector<int32_t> m_mixer_buffer_right;
sound_cache_entry *m_sound_cache;
sound_cache_entry *m_sound_cache_end;
sound_cache_entry *m_sound_cache_max;
@@ -111,7 +111,7 @@ private:
void fir_filter(int32_t *input, int16_t *output, int count);
void add_and_scale_samples(int ch, int32_t *dest, int samples, int volume);
- void mix_to_16(int length, stream_sample_t *dest_left, stream_sample_t *dest_right);
+ void mix_to_16(write_stream_view &dest_left, write_stream_view &dest_right);
uint8_t sound_command_r();
uint8_t sound_volume_r(offs_t offset);
diff --git a/src/mame/audio/flower.cpp b/src/mame/audio/flower.cpp
index 4ade0d864a9..99806a0c6b6 100644
--- a/src/mame/audio/flower.cpp
+++ b/src/mame/audio/flower.cpp
@@ -48,9 +48,7 @@ flower_sound_device::flower_sound_device(const machine_config &mconfig, const ch
device_memory_interface(mconfig, *this),
m_io_space_config("io", ENDIANNESS_LITTLE, 8, 7, 0, address_map_constructor(FUNC(flower_sound_device::regs_map), this)),
m_stream(nullptr),
- m_mixer_table(nullptr),
m_mixer_lookup(nullptr),
- m_mixer_buffer(nullptr),
m_last_channel(nullptr)
{
}
@@ -63,9 +61,9 @@ flower_sound_device::flower_sound_device(const machine_config &mconfig, const ch
void flower_sound_device::device_start()
{
m_iospace = &space(AS_IO);
- m_stream = stream_alloc_legacy(0, 1, clock()/2);
+ m_stream = stream_alloc(0, 1, clock()/2);
- m_mixer_buffer = make_unique_clear<short[]>(clock()/2);
+ m_mixer_buffer.resize(clock()/50);
make_mixer_table(MAX_VOICES, defgain);
m_last_channel = m_channel_list + MAX_VOICES;
@@ -94,10 +92,10 @@ void flower_sound_device::device_start()
void flower_sound_device::make_mixer_table(int voices, int gain)
{
/* allocate memory */
- m_mixer_table = make_unique_clear<int16_t[]>(256 * voices);
+ m_mixer_table.resize(256 * voices);
/* find the middle of the table */
- m_mixer_lookup = m_mixer_table.get() + (128 * voices);
+ m_mixer_lookup = &m_mixer_table[128 * voices];
/* fill in the table - 16 bit case */
for (int i = 0; i < voices * 128; i++)
@@ -127,13 +125,13 @@ void flower_sound_device::device_reset()
}
}
-void flower_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void flower_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];
short *mix;
uint8_t raw_sample;
- memset(m_mixer_buffer.get(), 0, samples * sizeof(short));
+ std::fill_n(&m_mixer_buffer[0], buffer.samples(), 0);
for (fl_sound_channel *voice = m_channel_list; voice < m_last_channel; voice++)
{
@@ -143,9 +141,9 @@ void flower_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
if (voice->enable == false)
continue;
- mix = m_mixer_buffer.get();
+ mix = &m_mixer_buffer[0];
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < buffer.samples(); i++)
{
if (voice->repeat == true)
{
@@ -174,9 +172,9 @@ void flower_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}
/* mix it down */
- mix = m_mixer_buffer.get();
- for (int i = 0; i < samples; i++)
- *buffer++ = m_mixer_lookup[*mix++];
+ mix = &m_mixer_buffer[0];
+ for (int i = 0; i < buffer.samples(); i++)
+ buffer.put_int(i, m_mixer_lookup[*mix++], 32768);
}
//-------------------------------------------------
diff --git a/src/mame/audio/flower.h b/src/mame/audio/flower.h
index 8fad33679c6..44787c6f30d 100644
--- a/src/mame/audio/flower.h
+++ b/src/mame/audio/flower.h
@@ -39,7 +39,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual space_config_vector memory_space_config() const override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
address_space *m_iospace;
private:
@@ -50,9 +50,9 @@ private:
static constexpr unsigned MAX_VOICES = 8;
static constexpr int defgain = 48;
- std::unique_ptr<int16_t[]> m_mixer_table;
+ std::vector<int16_t> m_mixer_table;
int16_t *m_mixer_lookup;
- std::unique_ptr<short[]> m_mixer_buffer;
+ std::vector<short> m_mixer_buffer;
struct fl_sound_channel
{
diff --git a/src/mame/audio/geebee.cpp b/src/mame/audio/geebee.cpp
index 63859916d7c..01858b5ecad 100644
--- a/src/mame/audio/geebee.cpp
+++ b/src/mame/audio/geebee.cpp
@@ -42,7 +42,7 @@ void geebee_sound_device::device_start()
m_decay[0x7fff - i] = (int16_t) (0x7fff/exp(1.0*i/4096));
/* 1V = HSYNC = 18.432MHz / 3 / 2 / 384 = 8000Hz */
- m_channel = stream_alloc_legacy(0, 1, clock() / 3 / 2 / 384);
+ m_channel = stream_alloc(0, 1, clock() / 3 / 2 / 384);
m_vcount = 0;
m_volume_timer = timer_alloc(TIMER_VOLUME_DECAY);
@@ -103,16 +103,16 @@ void geebee_sound_device::sound_w(u8 data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void geebee_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
- {
- stream_sample_t *buffer = outputs[0];
+void geebee_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
+{
+ auto &buffer = outputs[0];
- while (samples--)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- *buffer++ = m_sound_signal;
+ buffer.put_int(sampindex, m_sound_signal, 32768);
/* 1V = HSYNC = 18.432MHz / 3 / 2 / 384 = 8000Hz */
{
m_vcount++;
diff --git a/src/mame/audio/geebee.h b/src/mame/audio/geebee.h
index 1cca0fc6dd0..1bbddf36bba 100644
--- a/src/mame/audio/geebee.h
+++ b/src/mame/audio/geebee.h
@@ -22,7 +22,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
diff --git a/src/mame/audio/gomoku.cpp b/src/mame/audio/gomoku.cpp
index 6aeb288f6db..2b0d936bbd7 100644
--- a/src/mame/audio/gomoku.cpp
+++ b/src/mame/audio/gomoku.cpp
@@ -32,10 +32,6 @@ gomoku_sound_device::gomoku_sound_device(const machine_config &mconfig, const ch
, m_sound_rom(*this, DEVICE_SELF)
, m_sound_enable(0)
, m_stream(nullptr)
- , m_mixer_table(nullptr)
- , m_mixer_lookup(nullptr)
- , m_mixer_buffer(nullptr)
- , m_mixer_buffer_2(nullptr)
{
std::fill(std::begin(m_soundregs1), std::end(m_soundregs1), 0);
std::fill(std::begin(m_soundregs2), std::end(m_soundregs2), 0);
@@ -52,14 +48,10 @@ void gomoku_sound_device::device_start()
int ch;
// get stream channels
- m_stream = stream_alloc_legacy(0, 1, clock());
+ m_stream = stream_alloc(0, 1, clock());
- // allocate a pair of buffers to mix into - 1 second's worth should be more than enough
- m_mixer_buffer = std::make_unique<short[]>(2 * clock());
- m_mixer_buffer_2 = m_mixer_buffer.get() + clock(); // this is never used?
-
- // build the mixer table
- make_mixer_table(8, DEFGAIN);
+ // allocate a buffer to mix into - 1 second's worth should be more than enough
+ m_mixer_buffer.resize(clock()/50);
// start with sound enabled, many games don't have a sound enable register
m_sound_enable = 1;
@@ -76,7 +68,6 @@ void gomoku_sound_device::device_start()
save_item(NAME(m_soundregs1));
save_item(NAME(m_soundregs2));
- save_pointer(NAME(m_mixer_buffer), 2 * clock());
// save_item(NAME(m_sound_enable)); // set to 1 at device start and never updated?
save_item(STRUCT_MEMBER(m_channel_list, channel));
save_item(STRUCT_MEMBER(m_channel_list, frequency));
@@ -87,12 +78,12 @@ void gomoku_sound_device::device_start()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update in mono
+// sound_stream_update - handle a stream update in mono
//-------------------------------------------------
-void gomoku_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void gomoku_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];
sound_channel *voice;
short *mix;
int ch;
@@ -100,12 +91,12 @@ void gomoku_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 (ch = 0, voice = std::begin(m_channel_list); voice < std::end(m_channel_list); ch++, voice++)
@@ -124,10 +115,10 @@ void gomoku_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
else
w_base = 0x100 * (m_soundregs2[0x1d] & 0x0f);
- mix = m_mixer_buffer.get();
+ mix = &m_mixer_buffer[0];
// add our contribution
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < buffer.samples(); i++)
{
c += f;
@@ -167,31 +158,9 @@ void gomoku_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}
// mix it down
- mix = m_mixer_buffer.get();
- for (int i = 0; i < samples; i++)
- *buffer++ = m_mixer_lookup[*mix++];
-}
-
-
-// build a table to divide by the number of voices; gain is specified as gain*16
-void gomoku_sound_device::make_mixer_table(int voices, int gain)
-{
- int count = voices * 128;
-
- // allocate memory
- m_mixer_table = std::make_unique<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 < count; i++)
- {
- int val = i * gain * 16 / voices;
- if (val > 32767) val = 32767;
- m_mixer_lookup[ i] = val;
- m_mixer_lookup[-i] = -val;
- }
+ mix = &m_mixer_buffer[0];
+ for (int i = 0; i < buffer.samples(); i++)
+ buffer.put_int(i, *mix++, 128 * MAX_VOICES);
}
diff --git a/src/mame/audio/gomoku.h b/src/mame/audio/gomoku.h
index 75de8a2c09c..0c077de96bd 100644
--- a/src/mame/audio/gomoku.h
+++ b/src/mame/audio/gomoku.h
@@ -23,7 +23,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
void make_mixer_table(int voices, int gain);
@@ -52,10 +52,7 @@ private:
sound_stream *m_stream;
// mixer tables and internal buffers
- std::unique_ptr<int16_t[]> m_mixer_table;
- int16_t *m_mixer_lookup;
- std::unique_ptr<short[]> m_mixer_buffer;
- short *m_mixer_buffer_2;
+ std::vector<short> m_mixer_buffer;
uint8_t m_soundregs1[0x20];
uint8_t m_soundregs2[0x20];
diff --git a/src/mame/audio/gridlee.cpp b/src/mame/audio/gridlee.cpp
index 429518b39d0..2f6904c4efc 100644
--- a/src/mame/audio/gridlee.cpp
+++ b/src/mame/audio/gridlee.cpp
@@ -43,26 +43,26 @@ gridlee_sound_device::gridlee_sound_device(const machine_config &mconfig, const
void gridlee_sound_device::device_start()
{
/* allocate the stream */
- m_stream = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_stream = stream_alloc(0, 1, machine().sample_rate());
m_freq_to_step = (double)(1 << 24) / (double)machine().sample_rate();
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void gridlee_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void gridlee_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];
/* loop over samples */
- while (samples--)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
/* tone channel */
m_tone_fraction += m_tone_step;
- *buffer++ = (m_tone_fraction & 0x0800000) ? (m_tone_volume << 6) : 0;
+ buffer.put_int(sampindex, (m_tone_fraction & 0x0800000) ? m_tone_volume : 0, 32768 >> 6);
}
}
diff --git a/src/mame/audio/hyprolyb.cpp b/src/mame/audio/hyprolyb.cpp
index 77ff8034ae5..c97d5612d03 100644
--- a/src/mame/audio/hyprolyb.cpp
+++ b/src/mame/audio/hyprolyb.cpp
@@ -8,7 +8,6 @@ DEFINE_DEVICE_TYPE(HYPROLYB_ADPCM, hyprolyb_adpcm_device, "hyprolyb_adpcm", "Hyp
hyprolyb_adpcm_device::hyprolyb_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, HYPROLYB_ADPCM, tag, owner, clock)
- , device_sound_interface(mconfig, *this)
, m_audiocpu(*this, ":audiocpu")
, m_soundlatch2(*this, ":soundlatch2")
, m_msm(*this, ":msm")
@@ -80,13 +79,3 @@ void hyprolyb_adpcm_device::vck_callback( int st )
{
m_vck_ready = 0x80;
}
-
-//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
-//-------------------------------------------------
-
-void hyprolyb_adpcm_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
-{
- // should never get here
- fatalerror("sound_stream_update_legacy called; not applicable to legacy sound devices\n");
-}
diff --git a/src/mame/audio/hyprolyb.h b/src/mame/audio/hyprolyb.h
index ac2687b40e4..5d9ce541551 100644
--- a/src/mame/audio/hyprolyb.h
+++ b/src/mame/audio/hyprolyb.h
@@ -8,7 +8,7 @@
#include "machine/gen_latch.h"
#include "sound/msm5205.h"
-class hyprolyb_adpcm_device : public device_t, public device_sound_interface
+class hyprolyb_adpcm_device : public device_t
{
public:
hyprolyb_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@@ -27,9 +27,6 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
- // sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
-
private:
// internal state
required_device<cpu_device> m_audiocpu;
diff --git a/src/mame/audio/lynx.cpp b/src/mame/audio/lynx.cpp
index 40369d86d1d..d839a4c1704 100644
--- a/src/mame/audio/lynx.cpp
+++ b/src/mame/audio/lynx.cpp
@@ -172,7 +172,7 @@ void lynx_sound_device::init()
void lynx_sound_device::device_start()
{
- m_mixer_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_mixer_channel = stream_alloc(0, 1, machine().sample_rate());
m_usec_per_sample = 1000000 / machine().sample_rate();
m_timer_delegate.resolve();
init();
@@ -182,7 +182,7 @@ void lynx_sound_device::device_start()
void lynx2_sound_device::device_start()
{
- m_mixer_channel = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_mixer_channel = stream_alloc(0, 2, machine().sample_rate());
m_usec_per_sample = 1000000 / machine().sample_rate();
m_timer_delegate.resolve();
init();
@@ -467,39 +467,41 @@ void lynx_sound_device::write(offs_t offset, uint8_t data)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void lynx_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int v;
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
- for (int i = 0; i < samples; i++, buffer++)
+ for (int i = 0; i < buffer.samples(); i++)
{
- *buffer = 0;
+ s32 result = 0;
for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++)
{
execute(channel);
v = m_audio[channel].reg.output;
- *buffer += v * 15; // where does the *15 come from?
+ result += v * 15; // where does the *15 come from?
}
+ buffer.put_int(i, result, 32768);
}
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void lynx2_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void lynx2_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *left=outputs[0], *right=outputs[1];
+ auto &left=outputs[0];
+ auto &right=outputs[1];
int v;
- for (int i = 0; i < samples; i++, left++, right++)
+ for (int i = 0; i < left.samples(); i++)
{
- *left = 0;
- *right= 0;
+ s32 lsum = 0;
+ s32 rsum = 0;
for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++)
{
execute(channel);
@@ -507,17 +509,19 @@ void lynx2_sound_device::sound_stream_update_legacy(sound_stream &stream, stream
if (!(m_master_enable & (0x10 << channel)))
{
if (m_attenuation_enable & (0x10 << channel))
- *left += v * (m_audio[channel].attenuation >> 4);
+ lsum += v * (m_audio[channel].attenuation >> 4);
else
- *left += v * 15;
+ lsum += v * 15;
}
if (!(m_master_enable & (1 << channel)))
{
if (m_attenuation_enable & (1 << channel))
- *right += v * (m_audio[channel].attenuation & 0xf);
+ rsum += v * (m_audio[channel].attenuation & 0xf);
else
- *right += v * 15;
+ rsum += v * 15;
}
}
+ left.put_int(i, lsum, 32768);
+ right.put_int(i, rsum, 32768);
}
}
diff --git a/src/mame/audio/lynx.h b/src/mame/audio/lynx.h
index 11b983089a7..07bfef1a98b 100644
--- a/src/mame/audio/lynx.h
+++ b/src/mame/audio/lynx.h
@@ -45,7 +45,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void reset_channel(LYNX_AUDIO *channel);
void shift(int chan_nr);
@@ -75,7 +75,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
};
diff --git a/src/mame/audio/micro3d.cpp b/src/mame/audio/micro3d.cpp
index 52f723ef55f..5f38bdad788 100644
--- a/src/mame/audio/micro3d.cpp
+++ b/src/mame/audio/micro3d.cpp
@@ -68,9 +68,9 @@ void micro3d_sound_device::lp_filter::init(double fsval)
proto_coef[1].b1 = 1.847759;
proto_coef[1].b2 = 1.0;
- coef = make_unique_clear<float[]>(4 * 2 + 1);
+ std::fill(std::begin(coef), std::end(coef), 0);
fs = fsval;
- history = make_unique_clear<float[]>(2 * 2);
+ std::fill(std::begin(history), std::end(history), 0);
}
static void prewarp(double *a0, double *a1, double *a2,double fc, double fs)
@@ -104,7 +104,7 @@ static void bilinear(double a0, double a1, double a2,
void micro3d_sound_device::lp_filter::recompute(double k, double q, double fc)
{
- float *c = coef.get() + 1;
+ float *c = &coef[1];
for (int nInd = 0; nInd < 2; nInd++)
{
@@ -182,7 +182,7 @@ micro3d_sound_device::micro3d_sound_device(const machine_config &mconfig, const
void micro3d_sound_device::device_start()
{
/* Allocate the stream */
- m_stream = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_stream = stream_alloc(0, 2, machine().sample_rate());
m_filter.init(machine().sample_rate());
m_noise_filters[0].configure(2.7e3 + 2.7e3, 1.0e-6);
@@ -206,20 +206,20 @@ void micro3d_sound_device::device_reset()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void micro3d_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void micro3d_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
lp_filter *iir = &m_filter;
float pan_l, pan_r;
- stream_sample_t *fl = &outputs[0][0];
- stream_sample_t *fr = &outputs[1][0];
+ auto &fl = outputs[0];
+ auto &fr = outputs[1];
/* Clear the buffers */
- memset(outputs[0], 0, samples * sizeof(*outputs[0]));
- memset(outputs[1], 0, samples * sizeof(*outputs[1]));
+ fl.fill(0);
+ fr.fill(0);
if (m_gain == 0)
return;
@@ -227,7 +227,7 @@ void micro3d_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
pan_l = (float)(255 - m_dac[PAN]) / 255.0f;
pan_r = (float)(m_dac[PAN]) / 255.0f;
- while (samples--)
+ for (int sampindex = 0; sampindex < fl.samples(); sampindex++)
{
unsigned int i;
float *hist1_ptr,*hist2_ptr,*coef_ptr;
@@ -255,9 +255,9 @@ void micro3d_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
input += white;
input *= 200.0f;
- coef_ptr = iir->coef.get();
+ coef_ptr = &iir->coef[0];
- hist1_ptr = iir->history.get();
+ hist1_ptr = &iir->history[0];
hist2_ptr = hist1_ptr + 1;
/* 1st number of coefficients array is overall input scale factor, * or filter gain */
@@ -279,15 +279,9 @@ void micro3d_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
hist1_ptr++;
hist2_ptr++;
}
- output *= 3.5f;
+ output *= 3.5f / 32768.f;
- /* Clip */
- if (output > 32767)
- output = 32767;
- else if (output < -32768)
- output = -32768;
-
- *fl++ = output * pan_l;
- *fr++ = output * pan_r;
+ fl.put_clamp(sampindex, output * pan_l, 1.0);
+ fr.put_clamp(sampindex, output * pan_r, 1.0);
}
}
diff --git a/src/mame/audio/micro3d.h b/src/mame/audio/micro3d.h
index 937d1fbed74..04b2b284deb 100644
--- a/src/mame/audio/micro3d.h
+++ b/src/mame/audio/micro3d.h
@@ -24,7 +24,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
enum dac_registers {
@@ -45,8 +45,8 @@ private:
void init(double fs);
void recompute(double k, double q, double fc);
- std::unique_ptr<float[]> history;
- std::unique_ptr<float[]> coef;
+ float history[2 * 2];
+ float coef[4 * 2 + 1];
double fs;
biquad proto_coef[2];
};
diff --git a/src/mame/audio/phoenix.cpp b/src/mame/audio/phoenix.cpp
index 7c43519c186..772f4bb889a 100644
--- a/src/mame/audio/phoenix.cpp
+++ b/src/mame/audio/phoenix.cpp
@@ -89,7 +89,7 @@ void phoenix_sound_device::device_start()
m_poly18[i] = bits;
}
- m_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_channel = stream_alloc(0, 1, machine().sample_rate());
save_item(NAME(m_sound_latch_a));
save_item(NAME(m_c24_state.counter));
@@ -101,7 +101,6 @@ void phoenix_sound_device::device_start()
save_item(NAME(m_noise_state.polyoffs));
save_item(NAME(m_noise_state.lowpass_counter));
save_item(NAME(m_noise_state.lowpass_polybit));
- save_pointer(NAME(m_poly18), (1ul << (18-5)));
}
int phoenix_sound_device::update_c24(int samplerate)
@@ -520,18 +519,18 @@ void phoenix_sound_device::control_b_w(uint8_t data)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void phoenix_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void phoenix_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int samplerate = machine().sample_rate();
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
+ int samplerate = buffer.sample_rate();
- while( samples-- > 0 )
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
int sum = 0;
sum = noise(samplerate) / 2;
- *buffer++ = sum < 32768 ? sum > -32768 ? sum : -32768 : 32767;
+ buffer.put_int_clamp(sampindex, sum, 32768);
}
}
diff --git a/src/mame/audio/phoenix.h b/src/mame/audio/phoenix.h
index 6a02220c30e..30e6edfef10 100644
--- a/src/mame/audio/phoenix.h
+++ b/src/mame/audio/phoenix.h
@@ -22,7 +22,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
struct c_state
@@ -46,7 +46,7 @@ private:
struct n_state m_noise_state;
uint8_t m_sound_latch_a;
sound_stream * m_channel;
- std::unique_ptr<uint32_t[]> m_poly18;
+ std::unique_ptr<uint32_t[]> m_poly18;
required_device<discrete_device> m_discrete;
required_device<tms36xx_device> m_tms;
diff --git a/src/mame/audio/pleiads.cpp b/src/mame/audio/pleiads.cpp
index ee69320e7d6..965b445f67a 100644
--- a/src/mame/audio/pleiads.cpp
+++ b/src/mame/audio/pleiads.cpp
@@ -642,7 +642,7 @@ void pleiads_sound_device::common_start()
m_poly18[i] = bits;
}
- m_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_channel = stream_alloc(0, 1, machine().sample_rate());
save_item(NAME(m_sound_latch_a));
save_item(NAME(m_sound_latch_b));
@@ -691,27 +691,27 @@ void pleiads_sound_device::common_start()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void pleiads_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void pleiads_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int rate = machine().sample_rate();
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
+ int rate = buffer.sample_rate();
- while( samples-- > 0 )
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
int sum = tone1(rate)/2 + tone23(rate)/2 + tone4(rate) + noise(rate);
- *buffer++ = sum < 32768 ? sum > -32768 ? sum : -32768 : 32767;
+ buffer.put_int_clamp(sampindex, sum, 32768);
}
}
-void naughtyb_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void naughtyb_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- pleiads_sound_device::sound_stream_update_legacy(stream, inputs, outputs, samples);
+ pleiads_sound_device::sound_stream_update(stream, inputs, outputs);
}
-void popflame_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void popflame_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- pleiads_sound_device::sound_stream_update_legacy(stream, inputs, outputs, samples);
+ pleiads_sound_device::sound_stream_update(stream, inputs, outputs);
}
diff --git a/src/mame/audio/pleiads.h b/src/mame/audio/pleiads.h
index 0c4ef99b4a9..9dd77f6e857 100644
--- a/src/mame/audio/pleiads.h
+++ b/src/mame/audio/pleiads.h
@@ -51,7 +51,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void common_start();
inline int tone1(int samplerate);
@@ -105,7 +105,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
};
@@ -119,7 +119,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
};
diff --git a/src/mame/audio/polepos.cpp b/src/mame/audio/polepos.cpp
index 48865d300e0..a1dd8bc24dc 100644
--- a/src/mame/audio/polepos.cpp
+++ b/src/mame/audio/polepos.cpp
@@ -225,7 +225,7 @@ polepos_sound_device::polepos_sound_device(const machine_config &mconfig, const
void polepos_sound_device::device_start()
{
- m_stream = stream_alloc_legacy(0, 1, OUTPUT_RATE);
+ m_stream = stream_alloc(0, 1, OUTPUT_RATE);
m_sample_msb = m_sample_lsb = 0;
m_sample_enable = 0;
@@ -251,21 +251,21 @@ void polepos_sound_device::device_reset()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void polepos_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void polepos_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
uint32_t step, clock, slot;
uint8_t *base;
double volume, i_total;
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
int loop;
/* if we're not enabled, just fill with 0 */
if (!m_sample_enable)
{
- memset(buffer, 0, samples * sizeof(*buffer));
+ buffer.fill(0);
return;
}
@@ -279,7 +279,7 @@ void polepos_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
base = &machine().root_device().memregion("engine")->base()[slot * 0x800];
/* fill in the sample */
- while (samples--)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
m_filter_engine[0].x0 = (3.4 / 255 * base[(m_current_position >> 12) & 0x7ff] - 2) * volume;
m_filter_engine[1].x0 = m_filter_engine[0].x0;
@@ -296,9 +296,9 @@ void polepos_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
i_total += m_filter_engine[loop].y0 / r_filt_out[loop];
}
- i_total *= r_filt_total * 32000/2; /* now contains voltage adjusted by final gain */
+ i_total *= r_filt_total/2; /* now contains voltage adjusted by final gain */
- *buffer++ = (int)i_total;
+ buffer.put(sampindex, i_total);
m_current_position += step;
}
}
diff --git a/src/mame/audio/polepos.h b/src/mame/audio/polepos.h
index 430078088b2..b8611218284 100644
--- a/src/mame/audio/polepos.h
+++ b/src/mame/audio/polepos.h
@@ -19,7 +19,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
public:
DECLARE_WRITE_LINE_MEMBER(clson_w);
diff --git a/src/mame/audio/redbaron.cpp b/src/mame/audio/redbaron.cpp
index c08036c7d3b..51586a809fd 100644
--- a/src/mame/audio/redbaron.cpp
+++ b/src/mame/audio/redbaron.cpp
@@ -102,19 +102,19 @@ void redbaron_sound_device::device_start()
m_vol_crash[i] = 32767 * r0 / (r0 + r1);
}
- m_channel = stream_alloc_legacy(0, 1, OUTPUT_RATE);
+ m_channel = stream_alloc(0, 1, OUTPUT_RATE);
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void redbaron_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void redbaron_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];
- while( samples-- )
+ auto &buffer = outputs[0];
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
int sum = 0;
@@ -214,7 +214,7 @@ void redbaron_sound_device::sound_stream_update_legacy(sound_stream &stream, str
if( m_squeal_out )
sum += 32767 * 40 / 100;
- *buffer++ = sum;
+ buffer.put_int(sampindex, sum, 32768);
}
}
diff --git a/src/mame/audio/redbaron.h b/src/mame/audio/redbaron.h
index a66b74dff21..71f072ff44f 100644
--- a/src/mame/audio/redbaron.h
+++ b/src/mame/audio/redbaron.h
@@ -21,7 +21,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
std::unique_ptr<int16_t[]> m_vol_lookup;
diff --git a/src/mame/audio/segag80r.cpp b/src/mame/audio/segag80r.cpp
index 90a8463cbad..4acd7c2104a 100644
--- a/src/mame/audio/segag80r.cpp
+++ b/src/mame/audio/segag80r.cpp
@@ -46,7 +46,7 @@ void sega005_sound_device::device_start()
segag80r_state *state = machine().driver_data<segag80r_state>();
/* create the stream */
- m_sega005_stream = stream_alloc_legacy(0, 1, SEGA005_COUNTER_FREQ);
+ m_sega005_stream = stream_alloc(0, 1, SEGA005_COUNTER_FREQ);
/* create a timer for the 555 */
m_sega005_sound_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sega005_sound_device::sega005_auto_timer), this));
@@ -57,17 +57,17 @@ void sega005_sound_device::device_start()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void sega005_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void sega005_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
segag80r_state *state = machine().driver_data<segag80r_state>();
const uint8_t *sound_prom = state->memregion("proms")->base();
int i;
/* no implementation yet */
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
if (!(state->m_sound_state[1] & 0x10) && (++state->m_square_count & 0xff) == 0)
{
@@ -78,7 +78,7 @@ void sega005_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
state->m_square_state += 2;
}
- outputs[0][i] = (state->m_square_state & 2) ? 0x7fff : 0x0000;
+ outputs[0].put(i, (state->m_square_state & 2) ? 1.0 : 0.0);
}
}
diff --git a/src/mame/audio/segausb.cpp b/src/mame/audio/segausb.cpp
index ef6343e945d..dc87b73ae8c 100644
--- a/src/mame/audio/segausb.cpp
+++ b/src/mame/audio/segausb.cpp
@@ -100,7 +100,7 @@ void usb_sound_device::device_start()
#else
- m_stream = stream_alloc_legacy(0, 1, USB_2MHZ_CLOCK);
+ m_stream = stream_alloc(0, 1, USB_2MHZ_CLOCK);
m_noise_shift = 0x15555;
@@ -451,15 +451,15 @@ void usb_sound_device::env_w(int which, u8 offset, u8 data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void usb_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void usb_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *dest = outputs[0];
+ auto &dest = outputs[0];
// iterate over samples
- while (samples--)
+ for (int sampindex = 0; sampindex < dest.samples(); sampindex++)
{
/*----------------
Noise Source
@@ -590,7 +590,7 @@ void usb_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s
WEIGHT
*/
- *dest++ = 3000 * m_final_filter.step_cr(sample);
+ dest.put(sampindex, 0.1 * m_final_filter.step_cr(sample));
}
}
diff --git a/src/mame/audio/segausb.h b/src/mame/audio/segausb.h
index e34d892142d..e1e4a581782 100644
--- a/src/mame/audio/segausb.h
+++ b/src/mame/audio/segausb.h
@@ -62,7 +62,7 @@ protected:
#if (!ENABLE_SEGAUSB_NETLIST)
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
#endif
private:
diff --git a/src/mame/audio/seibu.cpp b/src/mame/audio/seibu.cpp
index 17075367960..57c6253fe9b 100644
--- a/src/mame/audio/seibu.cpp
+++ b/src/mame/audio/seibu.cpp
@@ -385,7 +385,7 @@ seibu_adpcm_device::seibu_adpcm_device(const machine_config &mconfig, const char
void seibu_adpcm_device::device_start()
{
m_playing = 0;
- m_stream = stream_alloc_legacy(0, 1, clock());
+ m_stream = stream_alloc(0, 1, clock());
m_adpcm.reset();
save_item(NAME(m_current));
@@ -443,14 +443,15 @@ void seibu_adpcm_device::ctl_w(u8 data)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void seibu_adpcm_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void seibu_adpcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *dest = outputs[0];
+ auto &dest = outputs[0];
- while (m_playing && samples > 0)
+ int sampindex;
+ for (sampindex = 0; m_playing && sampindex < dest.samples(); sampindex++)
{
int val = (m_base[m_current] >> m_nibble) & 15;
@@ -462,12 +463,7 @@ void seibu_adpcm_device::sound_stream_update_legacy(sound_stream &stream, stream
m_playing = 0;
}
- *dest++ = m_adpcm.clock(val) << 4;
- samples--;
- }
- while (samples > 0)
- {
- *dest++ = 0;
- samples--;
+ dest.put_int(sampindex, m_adpcm.clock(val), 32768 >> 4);
}
+ dest.fill(0, sampindex);
}
diff --git a/src/mame/audio/seibu.h b/src/mame/audio/seibu.h
index 9954b462205..1c53beb7746 100644
--- a/src/mame/audio/seibu.h
+++ b/src/mame/audio/seibu.h
@@ -145,7 +145,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
// internal state
diff --git a/src/mame/audio/snk6502.cpp b/src/mame/audio/snk6502.cpp
index 4d5550e08c3..0dc3b1868a5 100644
--- a/src/mame/audio/snk6502.cpp
+++ b/src/mame/audio/snk6502.cpp
@@ -165,7 +165,7 @@ void snk6502_sound_device::device_start()
// 38.99 Hz update (according to schematic)
set_music_clock(M_LN2 * (RES_K(18) * 2 + RES_K(1)) * CAP_U(1));
- m_tone_stream = stream_alloc_legacy(0, 1, SAMPLE_RATE);
+ m_tone_stream = stream_alloc(0, 1, SAMPLE_RATE);
for (int i = 0; i < NUM_CHANNELS; i++)
{
@@ -509,17 +509,17 @@ void snk6502_sound_device::speech_w(uint8_t data, const uint16_t *table, int sta
*/
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void snk6502_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void snk6502_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];
for (int i = 0; i < NUM_CHANNELS; i++)
validate_tone_channel(i);
- while (samples-- > 0)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
int32_t data = 0;
@@ -541,7 +541,7 @@ void snk6502_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
}
}
- *buffer++ = data;
+ buffer.put_int(sampindex, data, 3768);
m_tone_clock += FRAC_ONE;
if (m_tone_clock >= m_tone_clock_expire)
diff --git a/src/mame/audio/snk6502.h b/src/mame/audio/snk6502.h
index 99c0178120c..54474aa8207 100644
--- a/src/mame/audio/snk6502.h
+++ b/src/mame/audio/snk6502.h
@@ -40,7 +40,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
static constexpr unsigned NUM_CHANNELS = 3;
diff --git a/src/mame/audio/socrates.cpp b/src/mame/audio/socrates.cpp
index 4b49ec0b5bd..4f9731494eb 100644
--- a/src/mame/audio/socrates.cpp
+++ b/src/mame/audio/socrates.cpp
@@ -43,20 +43,20 @@ void socrates_snd_device::device_start()
m_DAC_output = 0x00; /* output */
m_state[0] = m_state[1] = m_state[2] = 0;
m_accum[0] = m_accum[1] = m_accum[2] = 0xFF;
- m_stream = stream_alloc_legacy(0, 1, clock() ? clock() : machine().sample_rate());
+ m_stream = stream_alloc(0, 1, clock() ? clock() : machine().sample_rate());
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void socrates_snd_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void socrates_snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < outputs[0].samples(); i++)
{
snd_clock();
- outputs[0][i] = ((int)m_DAC_output<<4);
+ outputs[0].put_int(i, (int)m_DAC_output, 32768 >> 4);
}
}
diff --git a/src/mame/audio/socrates.h b/src/mame/audio/socrates.h
index cd2d240079c..a75e5c1ca6f 100644
--- a/src/mame/audio/socrates.h
+++ b/src/mame/audio/socrates.h
@@ -22,7 +22,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
void snd_clock();
static const uint8_t s_volumeLUT[];
diff --git a/src/mame/audio/special.cpp b/src/mame/audio/special.cpp
index 9a1383bfec0..40442b2cfb2 100644
--- a/src/mame/audio/special.cpp
+++ b/src/mame/audio/special.cpp
@@ -41,41 +41,24 @@ specimx_sound_device::specimx_sound_device(const machine_config &mconfig, const
void specimx_sound_device::device_start()
{
m_specimx_input[0] = m_specimx_input[1] = m_specimx_input[2] = 0;
- m_mixer_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_mixer_channel = stream_alloc(0, 1, machine().sample_rate());
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void specimx_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void specimx_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int16_t channel_0_signal;
- int16_t channel_1_signal;
- int16_t channel_2_signal;
+ auto &sample_left = outputs[0];
- stream_sample_t *sample_left = outputs[0];
+ stream_buffer::sample_t channel_0_signal = m_specimx_input[0] ? 0.1 : -0.1;
+ stream_buffer::sample_t channel_1_signal = m_specimx_input[1] ? 0.1 : -0.1;
+ stream_buffer::sample_t channel_2_signal = m_specimx_input[2] ? 0.1 : -0.1;
+ stream_buffer::sample_t sum = channel_0_signal + channel_1_signal + channel_2_signal;
- channel_0_signal = m_specimx_input[0] ? 3000 : -3000;
- channel_1_signal = m_specimx_input[1] ? 3000 : -3000;
- channel_2_signal = m_specimx_input[2] ? 3000 : -3000;
-
- while (samples--)
- {
- *sample_left = 0;
-
- /* music channel 0 */
- *sample_left += channel_0_signal;
-
- /* music channel 1 */
- *sample_left += channel_1_signal;
-
- /* music channel 2 */
- *sample_left += channel_2_signal;
-
- sample_left++;
- }
+ sample_left.fill(sum);
}
diff --git a/src/mame/audio/special.h b/src/mame/audio/special.h
index daaa983a2d7..51dca82f12f 100644
--- a/src/mame/audio/special.h
+++ b/src/mame/audio/special.h
@@ -26,7 +26,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_mixer_channel;
diff --git a/src/mame/audio/svis_snd.cpp b/src/mame/audio/svis_snd.cpp
index 91fdd2dcce1..ed80d459821 100644
--- a/src/mame/audio/svis_snd.cpp
+++ b/src/mame/audio/svis_snd.cpp
@@ -45,22 +45,23 @@ void svision_sound_device::device_start()
memset(&m_noise, 0, sizeof(m_noise));
memset(m_channel, 0, sizeof(m_channel));
- m_mixer_channel = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_mixer_channel = stream_alloc(0, 2, machine().sample_rate());
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void svision_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void svision_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *left=outputs[0], *right=outputs[1];
+ auto &left=outputs[0];
+ auto &right=outputs[1];
- for (int i = 0; i < samples; i++, left++, right++)
+ for (int i = 0; i < left.samples(); i++)
{
- *left = 0;
- *right = 0;
+ s32 lsum = 0;
+ s32 rsum = 0;
for (int j = 0; j < ARRAY_LENGTH(m_channel); j++)
{
CHANNEL &channel(m_channel[j]);
@@ -88,9 +89,9 @@ void svision_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
{
int16_t s = on ? channel.volume << 8 : 0;
if (j == 0)
- *right += s;
+ rsum += s;
else
- *left += s;
+ lsum += s;
}
}
channel.pos++;
@@ -103,9 +104,9 @@ void svision_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
int16_t s = (m_noise.value ? 1 << 8: 0) * m_noise.volume;
int b1, b2;
if (m_noise.left)
- *left += s;
+ lsum += s;
if (m_noise.right)
- *right += s;
+ rsum += s;
m_noise.pos += m_noise.step;
if (m_noise.pos >= 1.0)
{
@@ -146,9 +147,9 @@ void svision_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
s = (sample & 0xf0) >> 4;
s <<= 8;
if (m_dma.left)
- *left += s;
+ lsum += s;
if (m_dma.right)
- *right += s;
+ rsum += s;
m_dma.pos += m_dma.step;
if (m_dma.pos >= m_dma.size)
{
@@ -157,6 +158,8 @@ void svision_sound_device::sound_stream_update_legacy(sound_stream &stream, stre
m_irq_cb(1);
}
}
+ left.put_int(i, lsum, 32768);
+ right.put_int(i, rsum, 32768);
}
}
diff --git a/src/mame/audio/svis_snd.h b/src/mame/audio/svis_snd.h
index 9b7efad6353..d080976261b 100644
--- a/src/mame/audio/svis_snd.h
+++ b/src/mame/audio/svis_snd.h
@@ -41,7 +41,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
struct NOISE
diff --git a/src/mame/audio/tiamc1.cpp b/src/mame/audio/tiamc1.cpp
index d99de897c22..67049496ceb 100644
--- a/src/mame/audio/tiamc1.cpp
+++ b/src/mame/audio/tiamc1.cpp
@@ -77,7 +77,7 @@ void tiamc1_sound_device::device_start()
timer8253_reset(&m_timer0);
timer8253_reset(&m_timer1);
- m_channel = stream_alloc_legacy(0, 1, clock() / CLOCK_DIVIDER);
+ m_channel = stream_alloc(0, 1, clock() / CLOCK_DIVIDER);
m_timer1_divider = 0;
@@ -104,14 +104,14 @@ void tiamc1_sound_device::device_start()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void tiamc1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void tiamc1_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int count, o0, o1, o2, len, orval = 0;
- len = samples * CLOCK_DIVIDER;
+ len = outputs[0].samples() * CLOCK_DIVIDER;
for (count = 0; count < len; count++)
{
@@ -140,7 +140,7 @@ void tiamc1_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
if ((count + 1) % CLOCK_DIVIDER == 0)
{
- outputs[0][count / CLOCK_DIVIDER] = orval ? 0x2828 : 0;
+ outputs[0].put(count / CLOCK_DIVIDER, orval ? 0.3 : 0.0);
orval = 0;
}
}
diff --git a/src/mame/audio/tiamc1.h b/src/mame/audio/tiamc1.h
index d8834816899..f469e8a40e0 100644
--- a/src/mame/audio/tiamc1.h
+++ b/src/mame/audio/tiamc1.h
@@ -25,7 +25,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
struct timer8253chan
diff --git a/src/mame/audio/timeplt.cpp b/src/mame/audio/timeplt.cpp
index 7fe94dd46c7..f626a8f98f9 100644
--- a/src/mame/audio/timeplt.cpp
+++ b/src/mame/audio/timeplt.cpp
@@ -34,7 +34,6 @@ locomotn_audio_device::locomotn_audio_device(const machine_config &mconfig, cons
timeplt_audio_device::timeplt_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
- , device_sound_interface(mconfig, *this)
, m_soundcpu(*this, "tpsound")
, m_soundlatch(*this, "soundlatch")
, m_filter_0(*this, "filter.0.%u", 0)
@@ -226,13 +225,3 @@ void locomotn_audio_device::device_add_mconfig(machine_config &config)
/* basic machine hardware */
m_soundcpu->set_addrmap(AS_PROGRAM, &locomotn_audio_device::locomotn_sound_map);
}
-
-//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
-//-------------------------------------------------
-
-void timeplt_audio_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
-{
- // should never get here
- fatalerror("sound_stream_update_legacy called; not applicable to legacy sound devices\n");
-}
diff --git a/src/mame/audio/timeplt.h b/src/mame/audio/timeplt.h
index 8e69d20caa1..b4e5b7c0677 100644
--- a/src/mame/audio/timeplt.h
+++ b/src/mame/audio/timeplt.h
@@ -10,7 +10,7 @@
#include "sound/ay8910.h"
#include "sound/flt_rc.h"
-class timeplt_audio_device : public device_t, public device_sound_interface
+class timeplt_audio_device : public device_t
{
public:
timeplt_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 14'318'181);
@@ -26,9 +26,6 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
- // sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
-
void filter_w(offs_t offset, uint8_t data);
uint8_t portB_r();
diff --git a/src/mame/audio/trackfld.cpp b/src/mame/audio/trackfld.cpp
index bf139f858e9..9a8a863d551 100644
--- a/src/mame/audio/trackfld.cpp
+++ b/src/mame/audio/trackfld.cpp
@@ -15,7 +15,6 @@ DEFINE_DEVICE_TYPE(TRACKFLD_AUDIO, trackfld_audio_device, "trackfld_audio", "Tra
trackfld_audio_device::trackfld_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, TRACKFLD_AUDIO, tag, owner, clock)
- , device_sound_interface(mconfig, *this)
, m_audiocpu(*this, finder_base::DUMMY_TAG)
, m_vlm(*this, finder_base::DUMMY_TAG)
, m_last_addr(0)
@@ -130,13 +129,3 @@ WRITE_LINE_MEMBER(trackfld_audio_device::sh_irqtrigger_w)
m_last_irq = state;
}
-
-//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
-//-------------------------------------------------
-
-void trackfld_audio_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
-{
- // should never get here
- fatalerror("sound_stream_update_legacy called; not applicable to legacy sound devices\n");
-}
diff --git a/src/mame/audio/trackfld.h b/src/mame/audio/trackfld.h
index f1502443562..141916cec65 100644
--- a/src/mame/audio/trackfld.h
+++ b/src/mame/audio/trackfld.h
@@ -8,7 +8,7 @@
#include "sound/vlm5030.h"
#include "cpu/m6800/m6800.h"
-class trackfld_audio_device : public device_t, public device_sound_interface
+class trackfld_audio_device : public device_t
{
public:
template <typename T, typename U>
@@ -33,9 +33,6 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
- // sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
-
private:
optional_device<cpu_device> m_audiocpu;
optional_device<vlm5030_device> m_vlm;
diff --git a/src/mame/audio/turrett.cpp b/src/mame/audio/turrett.cpp
index 4d8414b0118..a2f9ecdb5af 100644
--- a/src/mame/audio/turrett.cpp
+++ b/src/mame/audio/turrett.cpp
@@ -47,7 +47,7 @@ void turrett_device::device_start()
space().cache(m_cache);
// Create the sound stream
- m_stream = stream_alloc_legacy(0, 2, 44100);
+ m_stream = stream_alloc(0, 2, 44100);
// Create the volume table
for (int i = 0; i < 0x4f; ++i)
@@ -78,20 +78,17 @@ void turrett_device::device_reset()
//-------------------------------------------------
-// sound_stream_update_legacy - update sound stream
+// sound_stream_update - update sound stream
//-------------------------------------------------
-void turrett_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void turrett_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// Silence the buffers
- memset(outputs[0], 0x00, sizeof(stream_sample_t) * samples);
- memset(outputs[1], 0x00, sizeof(stream_sample_t) * samples);
+ outputs[0].fill(0);
+ outputs[1].fill(0);
for (int ch = 0; ch < SOUND_CHANNELS; ++ch)
{
- stream_sample_t *l = outputs[0];
- stream_sample_t *r = outputs[1];
-
if (m_channels[ch].m_playing)
{
uint32_t &addr = m_channels[ch].m_address;
@@ -104,7 +101,7 @@ void turrett_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
// Channels 30 and 31 expect interleaved stereo samples
uint32_t incr = (ch >= 30) ? 2 : 1;
- for (int s = 0; s < samples; ++s)
+ for (int s = 0; s < outputs[0].samples(); ++s)
{
int16_t sample = m_cache.read_word(addr << 1);
@@ -116,8 +113,8 @@ void turrett_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
addr += incr;
- *l++ += (sample * lvol) >> 17;
- *r++ += (sample * rvol) >> 17;
+ outputs[0].add_int(s, (sample * lvol) >> 17, 32768);
+ outputs[1].add_int(s, (sample * rvol) >> 17, 32768);
}
}
}
diff --git a/src/mame/audio/tvc.cpp b/src/mame/audio/tvc.cpp
index e30c79ef959..84495e0838b 100644
--- a/src/mame/audio/tvc.cpp
+++ b/src/mame/audio/tvc.cpp
@@ -31,7 +31,7 @@ void tvc_sound_device::device_start()
// resolve callbacks
m_write_sndint.resolve_safe();
- m_stream = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_stream = stream_alloc(0, 1, machine().sample_rate());
m_sndint_timer = timer_alloc(TIMER_SNDINT);
}
@@ -58,19 +58,19 @@ void tvc_sound_device::device_timer(emu_timer &timer, device_timer_id id, int pa
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void tvc_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void tvc_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int rate = machine().sample_rate() / 2;
- stream_sample_t *output = outputs[0];
+ auto &output = outputs[0];
+ int rate = output.sample_rate() / 2;
if (m_enabled && m_freq)
{
- while( samples-- > 0 )
+ for (int sampindex = 0; sampindex < output.samples(); sampindex++)
{
- *output++ = m_signal * (m_volume * 0x0800);
+ output.put_int(sampindex, m_signal * m_volume, 32768 / 0x0800);
m_incr -= m_freq;
while(m_incr < 0)
{
@@ -82,7 +82,7 @@ void tvc_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s
else
{
// fill output with 0 if the sound is disabled
- memset(output, 0, samples * sizeof(stream_sample_t));
+ output.fill(0);
}
}
diff --git a/src/mame/audio/tvc.h b/src/mame/audio/tvc.h
index 669184a0a2b..004ed6975bf 100644
--- a/src/mame/audio/tvc.h
+++ b/src/mame/audio/tvc.h
@@ -34,7 +34,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
static const device_timer_id TIMER_SNDINT = 0;
diff --git a/src/mame/audio/tx1.cpp b/src/mame/audio/tx1.cpp
index a6dd9d2aeb6..22f3e23ec5b 100644
--- a/src/mame/audio/tx1.cpp
+++ b/src/mame/audio/tx1.cpp
@@ -111,7 +111,7 @@ void tx1_sound_device::device_start()
/* Allocate the stream */
- m_stream = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_stream = stream_alloc(0, 2, machine().sample_rate());
m_freq_to_step = (double)(1 << TX1_FRAC) / (double)machine().sample_rate();
/* Compute the engine resistor weights */
@@ -356,20 +356,16 @@ static inline void update_engine(int eng[4])
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void tx1_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
uint32_t step_0, step_1, step_2;
double /*gain_0, gain_1,*/ gain_2, gain_3;
- stream_sample_t *fl = &outputs[0][0];
- stream_sample_t *fr = &outputs[1][0];
-
- /* Clear the buffers */
- memset(outputs[0], 0, samples * sizeof(*outputs[0]));
- memset(outputs[1], 0, samples * sizeof(*outputs[1]));
+ auto &fl = outputs[0];
+ auto &fr = outputs[1];
/* 8253 outputs for the player/opponent engine sounds. */
step_0 = m_pit8253.counts[0].val ? (TX1_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0;
@@ -381,7 +377,7 @@ void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s
gain_2 = tx1_engine_gains[m_ay_outputb & 0xf];
gain_3 = BIT(m_ay_outputb, 5) ? 1.0f : 1.5f;
- while (samples--)
+ for (int sampindex = 0; sampindex < fl.samples(); sampindex++)
{
if (m_step0 & ((1 << TX1_FRAC)))
{
@@ -404,8 +400,8 @@ void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s
m_step2 &= ((1 << TX1_FRAC) - 1);
}
- *fl++ = (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2;
- *fr++ = (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2;
+ fl.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768);
+ fr.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768);
m_step0 += step_0;
m_step1 += step_1;
@@ -662,7 +658,7 @@ void buggyboy_sound_device::device_start()
m_eng_voltages[i] = combine_weights(aweights, BIT(tmp[i], 0), BIT(tmp[i], 1), BIT(tmp[i], 2), BIT(tmp[i], 3));
/* Allocate the stream */
- m_stream = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_stream = stream_alloc(0, 2, machine().sample_rate());
m_freq_to_step = (double)(1 << 24) / (double)machine().sample_rate();
}
@@ -763,10 +759,10 @@ void buggyboy_sound_device::ym2_b_w(uint8_t data)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
/* This is admittedly a bit of a hack job... */
@@ -774,12 +770,8 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str
int n1_en, n2_en;
double gain0, gain1_l, gain1_r;
- stream_sample_t *fl = &outputs[0][0];
- stream_sample_t *fr = &outputs[1][0];
-
- /* Clear the buffers */
- memset(outputs[0], 0, samples * sizeof(*outputs[0]));
- memset(outputs[1], 0, samples * sizeof(*outputs[1]));
+ auto &fl = outputs[0];
+ auto &fr = outputs[1];
/* 8253 outputs for the player/opponent buggy engine sounds. */
step_0 = m_pit8253.counts[0].val ? (BUGGYBOY_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0;
@@ -796,10 +788,10 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str
gain1_l = bb_engine_gains[m_ym2_outputa >> 4] * 5;
gain1_r = bb_engine_gains[m_ym2_outputa & 0xf] * 5;
- while (samples--)
+ for (int sampindex = 0; sampindex < fl.samples(); sampindex++)
{
int i;
- stream_sample_t pit0, pit1, n1, n2;
+ s32 pit0, pit1, n1, n2;
pit0 = m_eng_voltages[(m_step0 >> 24) & 0xf];
pit1 = m_eng_voltages[(m_step1 >> 24) & 0xf];
@@ -839,8 +831,8 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str
else
n2 = 8192;
- *fl++ = n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l);
- *fr++ = n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r);
+ fl.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l), 32768);
+ fr.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r), 32768);
m_step0 += step_0;
m_step1 += step_1;
diff --git a/src/mame/audio/tx1.h b/src/mame/audio/tx1.h
index 71e228e324c..8d8e4d49739 100644
--- a/src/mame/audio/tx1.h
+++ b/src/mame/audio/tx1.h
@@ -73,7 +73,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void tx1_sound_io(address_map &map);
void tx1_sound_prg(address_map &map);
@@ -104,9 +104,9 @@ protected:
uint8_t m_ppi_latch_b = 0;
uint32_t m_ts = 0;
- stream_sample_t m_pit0 = 0;
- stream_sample_t m_pit1 = 0;
- stream_sample_t m_pit2 = 0;
+ s32 m_pit0 = 0;
+ s32 m_pit1 = 0;
+ s32 m_pit2 = 0;
double m_weights0[4] = { 0, 0, 0, 0 };
double m_weights1[3] = { 0, 0, 0 };
@@ -155,7 +155,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void ym1_a_w(uint8_t data);
diff --git a/src/mame/audio/vboy.cpp b/src/mame/audio/vboy.cpp
index 37eec2ee80b..56aa88e9054 100644
--- a/src/mame/audio/vboy.cpp
+++ b/src/mame/audio/vboy.cpp
@@ -209,7 +209,7 @@ void vboysnd_device::device_start()
{
uint32_t rate = clock() / 120;
// create the stream
- m_stream = stream_alloc_legacy(0, 2, rate);
+ m_stream = stream_alloc(0, 2, rate);
m_timer = timer_alloc(0, nullptr);
m_timer->adjust(attotime::zero, 0, rate ? attotime::from_hz(rate / 4) : attotime::never);
@@ -265,19 +265,18 @@ void vboysnd_device::device_timer(emu_timer &timer, device_timer_id tid, int par
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void vboysnd_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void vboysnd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *outL, *outR;
int len, i, j, channel;
- outL = outputs[0];
- outR = outputs[1];
+ auto &outL = outputs[0];
+ auto &outR = outputs[1];
- len = samples;
+ len = outL.samples();
// if (mgetb(m_aram+SST0P) & 0x1) // Sound Stop Reg
// goto end;
@@ -384,13 +383,9 @@ void vboysnd_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
// scale to 16 bits
note_left = (note_left << 5) | ((note_left >> 6) & 0x1f);
note_right = (note_right << 5) | ((note_right >> 6) & 0x1f);
- if (note_left < -32767) note_left = -32767;
- if (note_left > 32767) note_left = 32767;
- if (note_right < -32767) note_right = -32767;
- if (note_right > 32767) note_right = 32767;
- *(outL++) = ((int16_t)note_left);
- *(outR++) = ((int16_t)note_right);
+ outL.put_int_clamp(j, (int16_t)note_left, 32768);
+ outR.put_int_clamp(j, (int16_t)note_right, 32768);
}
}
diff --git a/src/mame/audio/vboy.h b/src/mame/audio/vboy.h
index f8d3a050272..ca4de746db3 100644
--- a/src/mame/audio/vboy.h
+++ b/src/mame/audio/vboy.h
@@ -72,7 +72,7 @@ protected:
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
s_snd_channel snd_channel[5];
diff --git a/src/mame/audio/vc4000.cpp b/src/mame/audio/vc4000.cpp
index 84c19a2d942..0454af936a5 100644
--- a/src/mame/audio/vc4000.cpp
+++ b/src/mame/audio/vc4000.cpp
@@ -31,26 +31,22 @@ vc4000_sound_device::vc4000_sound_device(const machine_config &mconfig, const ch
void vc4000_sound_device::device_start()
{
- m_channel = stream_alloc_legacy(0, 1, machine().sample_rate());
+ m_channel = stream_alloc(0, 1, machine().sample_rate());
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void vc4000_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void vc4000_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int i;
- stream_sample_t *buffer = outputs[0];
+ auto &buffer = outputs[0];
- for (i = 0; i < samples; i++, buffer++)
+ for (i = 0; i < buffer.samples(); i++)
{
- *buffer = 0;
- if (m_reg[0] && m_pos <= m_size / 2)
- {
- *buffer = 0x7fff;
- }
+ buffer.put(i, (m_reg[0] && m_pos <= m_size / 2) ? 1.0 : 0.0);
if (m_pos <= m_size)
m_pos++;
if (m_pos > m_size)
diff --git a/src/mame/audio/vc4000.h b/src/mame/audio/vc4000.h
index 3917ffa2776..2dad7a87d27 100644
--- a/src/mame/audio/vc4000.h
+++ b/src/mame/audio/vc4000.h
@@ -28,7 +28,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
public:
void soundport_w(int mode, int data);
diff --git a/src/mame/audio/warpwarp.cpp b/src/mame/audio/warpwarp.cpp
index 9e00ff069fd..5ef7e52659c 100644
--- a/src/mame/audio/warpwarp.cpp
+++ b/src/mame/audio/warpwarp.cpp
@@ -52,7 +52,7 @@ void warpwarp_sound_device::device_start()
m_clock_16h = clock() / 3 / 2 / 16;
m_clock_1v = clock() / 3 / 2 / 384;
- m_channel = stream_alloc_legacy(0, 1, m_clock_16h);
+ m_channel = stream_alloc(0, 1, m_clock_16h);
m_sound_volume_timer = timer_alloc(TIMER_SOUND_VOLUME_DECAY);
m_music_volume_timer = timer_alloc(TIMER_MUSIC_VOLUME_DECAY);
@@ -169,16 +169,16 @@ void warpwarp_sound_device::music2_w(u8 data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void warpwarp_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
- {
- stream_sample_t *buffer = outputs[0];
+void warpwarp_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
+{
+ auto &buffer = outputs[0];
- while (samples--)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- *buffer++ = (m_sound_signal + m_music_signal) / 2;
+ buffer.put_int(sampindex, m_sound_signal + m_music_signal, 32768 * 2);
/*
* The music signal is selected at a rate of 2H (1.536MHz) from the
diff --git a/src/mame/audio/warpwarp.h b/src/mame/audio/warpwarp.h
index 7bf06a4dc25..d4bcdc15d23 100644
--- a/src/mame/audio/warpwarp.h
+++ b/src/mame/audio/warpwarp.h
@@ -27,7 +27,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
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);
}
diff --git a/src/mame/audio/wiping.h b/src/mame/audio/wiping.h
index d10a26d2848..1f50683387e 100644
--- a/src/mame/audio/wiping.h
+++ b/src/mame/audio/wiping.h
@@ -17,7 +17,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
/* 8 voices max */
@@ -48,10 +48,7 @@ private:
sound_stream *m_stream;
/* mixer tables and internal buffers */
- std::unique_ptr<int16_t[]> m_mixer_table;
- int16_t *m_mixer_lookup;
- std::unique_ptr<short[]> m_mixer_buffer;
- std::unique_ptr<short[]> m_mixer_buffer_2;
+ std::vector<short> m_mixer_buffer;
uint8_t m_soundregs[0x4000];
diff --git a/src/mame/audio/wswan.cpp b/src/mame/audio/wswan.cpp
index 0e6442cea6d..6f956ffb57c 100644
--- a/src/mame/audio/wswan.cpp
+++ b/src/mame/audio/wswan.cpp
@@ -62,7 +62,7 @@ constexpr int clk_div = 64;
void wswan_sound_device::device_start()
{
- m_channel = stream_alloc_legacy(0, 2, clock() / clk_div);
+ m_channel = stream_alloc(0, 2, clock() / clk_div);
save_item(NAME(m_sweep_step));
save_item(NAME(m_sweep_time));
@@ -164,16 +164,16 @@ int wswan_sound_device::fetch_sample(int channel, int offset)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void wswan_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t sample, left, right;
+ s32 sample, left, right;
- stream_sample_t *outputl = outputs[0];
- stream_sample_t *outputr = outputs[1];
- while( samples-- > 0 )
+ auto &outputl = outputs[0];
+ auto &outputr = outputs[1];
+ for (int sampindex = 0; sampindex < outputl.samples(); sampindex++)
{
left = right = 0;
@@ -268,11 +268,8 @@ void wswan_sound_device::sound_stream_update_legacy(sound_stream &stream, stream
right += m_audio4.vol_right * sample;
}
- left <<= 5;
- right <<= 5;
-
- *outputl++ = left;
- *outputr++ = right;
+ outputl.put_int(sampindex, left, 32768 >> 5);
+ outputr.put_int(sampindex, right, 32768 >> 5);
}
}
diff --git a/src/mame/audio/wswan.h b/src/mame/audio/wswan.h
index e3c4974bf54..f21ad6adbc5 100644
--- a/src/mame/audio/wswan.h
+++ b/src/mame/audio/wswan.h
@@ -59,7 +59,7 @@ protected:
virtual void rom_bank_updated() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
void wswan_ch_set_freq( CHAN *ch, uint16_t freq );
diff --git a/src/mame/audio/xavix.cpp b/src/mame/audio/xavix.cpp
index a4b2d12dccb..ab5b2387a86 100644
--- a/src/mame/audio/xavix.cpp
+++ b/src/mame/audio/xavix.cpp
@@ -27,7 +27,7 @@ void xavix_sound_device::device_start()
m_readregs_cb.resolve_safe(0xff);
m_readsamples_cb.resolve_safe(0x80);
- m_stream = stream_alloc_legacy(0, 2, 163840);
+ m_stream = stream_alloc(0, 2, 163840);
}
void xavix_sound_device::device_reset()
@@ -43,14 +43,15 @@ void xavix_sound_device::device_reset()
}
-void xavix_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void xavix_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// reset the output stream
- memset(outputs[0], 0, samples * sizeof(*outputs[0]));
- memset(outputs[1], 0, samples * sizeof(*outputs[1]));
+ outputs[0].fill(0);
+ outputs[1].fill(0);
int outpos = 0;
// loop while we still have samples to generate
+ int samples = outputs[0].samples();
while (samples-- != 0)
{
for (int channel = 0; channel < 2; channel++)
@@ -83,7 +84,7 @@ void xavix_sound_device::sound_stream_update_legacy(sound_stream &stream, stream
*/
}
- outputs[channel][outpos] += sample * (m_voice[v].vol + 1);
+ outputs[channel].add_int(outpos, sample * (m_voice[v].vol + 1), 32768);
m_voice[v].position[channel] += m_voice[v].rate;
}
else
diff --git a/src/mame/drivers/esq1.cpp b/src/mame/drivers/esq1.cpp
index b0a9e97a293..c7f4869c33d 100644
--- a/src/mame/drivers/esq1.cpp
+++ b/src/mame/drivers/esq1.cpp
@@ -210,7 +210,7 @@ protected:
virtual void device_start() override;
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
struct filter {
@@ -334,13 +334,13 @@ void esq1_filters::recalc_filter(filter &f)
void esq1_filters::device_start()
{
- stream = stream_alloc_legacy(8, 2, 44100);
+ stream = stream_alloc(8, 2, 44100);
memset(filters, 0, sizeof(filters));
for(auto & elem : filters)
recalc_filter(elem);
}
-void esq1_filters::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void esq1_filters::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
/* if(0) {
for(int i=0; i<8; i++)
@@ -352,11 +352,11 @@ void esq1_filters::sound_stream_update_legacy(sound_stream &stream, stream_sampl
fprintf(stderr, "\n");
}*/
- for(int i=0; i<samples; i++) {
+ for(int i=0; i<outputs[0].samples(); i++) {
double l=0, r=0;
for(int j=0; j<8; j++) {
filter &f = filters[j];
- double x = inputs[j][i];
+ double x = inputs[j].get(i);
double y = (x*f.a[0]
+ f.x[0]*f.a[1] + f.x[1]*f.a[2] + f.x[2]*f.a[3] + f.x[3]*f.a[4]
- f.y[0]*f.b[1] - f.y[1]*f.b[2] - f.y[2]*f.b[3] - f.y[3]*f.b[4]) / f.b[0];
@@ -378,8 +378,8 @@ void esq1_filters::sound_stream_update_legacy(sound_stream &stream, stream_sampl
// r *= 6553;
l *= 2;
r *= 2;
- outputs[0][i] = l < -32768 ? -32768 : l > 32767 ? 32767 : int(l);
- outputs[1][i] = r < -32768 ? -32768 : r > 32767 ? 32767 : int(r);
+ outputs[0].put_clamp(i, l, 1.0);
+ outputs[1].put_clamp(i, r, 1.0);
}
}
diff --git a/src/mame/drivers/istrebiteli.cpp b/src/mame/drivers/istrebiteli.cpp
index a1ba11ca972..065c5329159 100644
--- a/src/mame/drivers/istrebiteli.cpp
+++ b/src/mame/drivers/istrebiteli.cpp
@@ -45,7 +45,7 @@ protected:
virtual void device_start() override;
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
// internal state
@@ -81,15 +81,15 @@ istrebiteli_sound_device::istrebiteli_sound_device(const machine_config &mconfig
void istrebiteli_sound_device::device_start()
{
- m_channel = stream_alloc_legacy(0, 1, clock() / 2);
+ m_channel = stream_alloc(0, 1, clock() / 2);
m_rom = machine().root_device().memregion("soundrom")->base();
}
-void istrebiteli_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void istrebiteli_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *sample = outputs[0];
+ auto &buffer = outputs[0];
- while (samples-- > 0)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
int smpl = 0;
if (m_rom_out_en)
@@ -100,7 +100,7 @@ void istrebiteli_sound_device::sound_stream_update_legacy(sound_stream &stream,
smpl &= machine().rand() & 1;
smpl *= (m_prev_data & 0x80) ? 1000 : 4000; // b7 volume ?
- *sample++ = smpl;
+ buffer.put_int(sampindex, smpl, 32768);
m_rom_cnt = (m_rom_cnt + m_rom_incr) & 0x1ff;
}
}
diff --git a/src/mame/drivers/milton6805.cpp b/src/mame/drivers/milton6805.cpp
index efda2a0886d..1377e8d85a2 100644
--- a/src/mame/drivers/milton6805.cpp
+++ b/src/mame/drivers/milton6805.cpp
@@ -90,7 +90,7 @@ public:
protected:
virtual void device_start() override;
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_stream;
@@ -108,25 +108,24 @@ milton_filter_device::milton_filter_device(const machine_config &mconfig, const
void milton_filter_device::device_start()
{
- m_stream = stream_alloc_legacy(1, 1, machine().sample_rate());
+ m_stream = stream_alloc(1, 1, machine().sample_rate());
m_led_out.resolve();
}
-void milton_filter_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void milton_filter_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int level = 0;
+ stream_buffer::sample_t level = 0;
- for (int i = 0; i < samples; i++)
- {
- level += abs(inputs[0][i]);
- outputs[0][i] = inputs[0][i];
- }
+ for (int i = 0; i < outputs[0].samples(); i++)
+ level += fabsf(inputs[0].get(i));
+
+ outputs[0] = inputs[0];
- if (samples > 0)
- level /= samples;
+ if (outputs[0].samples() > 0)
+ level /= outputs[0].samples();
// 2 leds connected to the audio circuit
- const int threshold = 1500;
+ const stream_buffer::sample_t threshold = 1500.0 / 32768.0;
m_led_out = (level > threshold) ? 1 : 0;
}
diff --git a/src/mame/drivers/ninjaw.cpp b/src/mame/drivers/ninjaw.cpp
index 3cff502baf7..1a6c4e58760 100644
--- a/src/mame/drivers/ninjaw.cpp
+++ b/src/mame/drivers/ninjaw.cpp
@@ -618,7 +618,7 @@ protected:
virtual void device_start();
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples);
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
// internal state
@@ -654,11 +654,12 @@ void subwoofer_device::device_start()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void subwoofer_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void subwoofer_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
+ outputs[0].fill(0);
}
diff --git a/src/mame/drivers/pv1000.cpp b/src/mame/drivers/pv1000.cpp
index a78004c2ad4..63b19c16975 100644
--- a/src/mame/drivers/pv1000.cpp
+++ b/src/mame/drivers/pv1000.cpp
@@ -31,7 +31,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
@@ -60,7 +60,7 @@ pv1000_sound_device::pv1000_sound_device(const machine_config &mconfig, const ch
void pv1000_sound_device::device_start()
{
- m_sh_channel = stream_alloc_legacy(0, 1, clock() / 1024);
+ m_sh_channel = stream_alloc(0, 1, clock() / 1024);
save_item(NAME(m_voice[0].count));
save_item(NAME(m_voice[0].period));
@@ -84,7 +84,7 @@ void pv1000_sound_device::voice_w(offs_t offset, uint8_t data)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
@@ -98,20 +98,20 @@ void pv1000_sound_device::voice_w(offs_t offset, uint8_t data)
Note: the register periods are inverted.
*/
-void pv1000_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void pv1000_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];
- while (samples > 0)
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- *buffer=0;
+ s32 sum = 0;
for (int i = 0; i < 3; i++)
{
uint32_t per = (0x3f - (m_voice[i].period & 0x3f));
if (per != 0) //OFF!
- *buffer += m_voice[i].val * 8192;
+ sum += m_voice[i].val * 8192;
m_voice[i].count++;
@@ -122,8 +122,7 @@ void pv1000_sound_device::sound_stream_update_legacy(sound_stream &stream, strea
}
}
- buffer++;
- samples--;
+ buffer.put_int(sampindex, sum, 32768);
}
}
diff --git a/src/mame/includes/gridlee.h b/src/mame/includes/gridlee.h
index 59314a1e903..5fbf6db267f 100644
--- a/src/mame/includes/gridlee.h
+++ b/src/mame/includes/gridlee.h
@@ -101,7 +101,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
public:
void gridlee_sound_w(offs_t offset, uint8_t data);
diff --git a/src/mame/includes/segag80r.h b/src/mame/includes/segag80r.h
index 14bb5af7651..fe04be66d4d 100644
--- a/src/mame/includes/segag80r.h
+++ b/src/mame/includes/segag80r.h
@@ -211,7 +211,7 @@ protected:
virtual void device_start() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
// internal state
diff --git a/src/mame/includes/turrett.h b/src/mame/includes/turrett.h
index cce1f821f56..6192a5f56ff 100644
--- a/src/mame/includes/turrett.h
+++ b/src/mame/includes/turrett.h
@@ -121,7 +121,7 @@ protected:
virtual void device_reset() override;
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
// device_memory_interface overrides
virtual space_config_vector memory_space_config() const override;
diff --git a/src/mame/includes/xavix.h b/src/mame/includes/xavix.h
index 22d4b584d3a..7f24498bbf3 100644
--- a/src/mame/includes/xavix.h
+++ b/src/mame/includes/xavix.h
@@ -48,7 +48,7 @@ protected:
virtual void device_reset() override;
// sound stream update overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
sound_stream *m_stream;
diff --git a/src/mame/machine/mega32x.cpp b/src/mame/machine/mega32x.cpp
index b8607d8506a..40af33a6965 100644
--- a/src/mame/machine/mega32x.cpp
+++ b/src/mame/machine/mega32x.cpp
@@ -935,13 +935,10 @@ void sega_32x_device::m68k_pwm_w(offs_t offset, uint16_t data)
pwm_w(offset,data);
}
-void sega_32x_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void sega_32x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- for (int s = 0; s < samples; s++)
- {
- outputs[0][s] = inputs[0][s];
- outputs[1][s] = inputs[1][s];
- }
+ outputs[0] = inputs[0];
+ outputs[1] = inputs[1];
}
/**********************************************************************************************/
@@ -1742,7 +1739,7 @@ void sega_32x_device::device_start()
set_pen_color(i, pal5bit(r), pal5bit(g), pal5bit(b));
}
- m_stream = stream_alloc_legacy(2, 2, 48000 * 4);
+ m_stream = stream_alloc(2, 2, 48000 * 4);
m_32x_pwm_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sega_32x_device::handle_pwm_callback), this));
m_32x_dram0 = std::make_unique<uint16_t[]>(0x40000/2);
diff --git a/src/mame/machine/mega32x.h b/src/mame/machine/mega32x.h
index e56db24fdb3..51cdf07ad47 100644
--- a/src/mame/machine/mega32x.h
+++ b/src/mame/machine/mega32x.h
@@ -110,7 +110,7 @@ protected:
virtual uint32_t palette_entries() const override { return 32*32*32/**2*/; }
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
void update_total_scanlines(bool mode3) { m_total_scanlines = mode3 ? (m_base_total_scanlines * 2) : m_base_total_scanlines; } // this gets set at each EOF
diff --git a/src/mame/video/gic.cpp b/src/mame/video/gic.cpp
index 320b862d920..65deaf5b7f7 100644
--- a/src/mame/video/gic.cpp
+++ b/src/mame/video/gic.cpp
@@ -118,7 +118,7 @@ void gic_device::device_start()
m_vblank_timer->adjust( screen().time_until_pos(1, END_ACTIVE_SCAN + 18 ), 0, screen().scan_period() );
// allocate the audio stream
- m_stream = stream_alloc_legacy( 0, 1, clock()/(2*228) );
+ m_stream = stream_alloc( 0, 1, clock()/(2*228) );
m_ram.resolve_safe(0xff);
}
@@ -252,9 +252,9 @@ void gic_device::device_timer(emu_timer &timer, device_timer_id id, int param, v
#define GIC_AUDIO_BYTE 0x96
-void gic_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void gic_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];
//Audio is basic and badly implemented (doubt that was the intent)
//The datasheet lists the 3 different frequencies the GIC can generate: 500,1000 and 2000Hz
@@ -298,8 +298,7 @@ void gic_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_
uint8_t audioByte = m_ram(GIC_AUDIO_BYTE)*2;
if(!audioByte){
- for(size_t i = 0; i < samples; i++)
- *buffer++ = 0;
+ buffer.fill(0);
m_audioval = 0;
m_audiocnt = 0;
@@ -314,12 +313,12 @@ void gic_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_
m_audioreset = 0;
}
- for(size_t i=0; i < samples; i++){
+ for(size_t i=0; i < buffer.samples(); i++){
m_audiocnt++;
if(m_audiocnt >= audioByte){
m_audioval = !m_audioval;
m_audiocnt=0;
}
- *buffer++ = m_audioval<<13;
+ buffer.put(i, m_audioval ? 1.0 : 0.0);
}
}
diff --git a/src/mame/video/gic.h b/src/mame/video/gic.h
index a393b88c4e2..579ddec7b12 100644
--- a/src/mame/video/gic.h
+++ b/src/mame/video/gic.h
@@ -74,7 +74,7 @@ protected:
virtual const tiny_rom_entry *device_rom_region() const override;
// device_sound_interface overrides
- virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
/* timers */
static const device_timer_id TIMER_VBLANK = 0;