summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-21 20:45:38 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-21 20:45:38 -0700
commitf051f97e6c16374bf2612b98be4c67d64695cbd7 (patch)
tree25fb85c2f134676fc4de852097140ca088ed1775
parentecd3333757e171d5d98bc323dba1f7c403386e11 (diff)
ym2203/ym2608/ym2610/ym2612/ymf262/ym3526/ym3812/y8950/ym2413/ymf271/ymf278b/ymz280b/ymz770/zsg2: update to new stream callbacks
-rw-r--r--src/devices/sound/2203intf.cpp9
-rw-r--r--src/devices/sound/2203intf.h2
-rw-r--r--src/devices/sound/2608intf.cpp8
-rw-r--r--src/devices/sound/2608intf.h2
-rw-r--r--src/devices/sound/2610intf.cpp14
-rw-r--r--src/devices/sound/2610intf.h4
-rw-r--r--src/devices/sound/2612intf.cpp10
-rw-r--r--src/devices/sound/2612intf.h2
-rw-r--r--src/devices/sound/262intf.cpp8
-rw-r--r--src/devices/sound/262intf.h2
-rw-r--r--src/devices/sound/3526intf.cpp8
-rw-r--r--src/devices/sound/3526intf.h2
-rw-r--r--src/devices/sound/3812intf.cpp8
-rw-r--r--src/devices/sound/3812intf.h2
-rw-r--r--src/devices/sound/8950intf.cpp8
-rw-r--r--src/devices/sound/8950intf.h2
-rw-r--r--src/devices/sound/fm.cpp66
-rw-r--r--src/devices/sound/fm.h10
-rw-r--r--src/devices/sound/fm2612.cpp13
-rw-r--r--src/devices/sound/fmopl.cpp39
-rw-r--r--src/devices/sound/fmopl.h6
-rw-r--r--src/devices/sound/ym2413.cpp12
-rw-r--r--src/devices/sound/ym2413.h2
-rw-r--r--src/devices/sound/ymf262.cpp30
-rw-r--r--src/devices/sound/ymf262.h2
-rw-r--r--src/devices/sound/ymf271.cpp32
-rw-r--r--src/devices/sound/ymf271.h2
-rw-r--r--src/devices/sound/ymf278b.cpp30
-rw-r--r--src/devices/sound/ymf278b.h2
-rw-r--r--src/devices/sound/ymz280b.cpp35
-rw-r--r--src/devices/sound/ymz280b.h2
-rw-r--r--src/devices/sound/ymz770.cpp18
-rw-r--r--src/devices/sound/ymz770.h2
-rw-r--r--src/devices/sound/zsg2.cpp11
-rw-r--r--src/devices/sound/zsg2.h2
35 files changed, 175 insertions, 232 deletions
diff --git a/src/devices/sound/2203intf.cpp b/src/devices/sound/2203intf.cpp
index 6b579f486a3..3a1a31d26a2 100644
--- a/src/devices/sound/2203intf.cpp
+++ b/src/devices/sound/2203intf.cpp
@@ -54,13 +54,12 @@ void ym2203_device::timer_handler(int c, int count, int clock)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// stream_generate - handle a stream update
//-------------------------------------------------
-
-void ym2203_device::stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2203_device::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym2203_update_one(m_chip, outputs[0], samples);
+ ym2203_update_one(m_chip, outputs[0]);
}
@@ -108,7 +107,7 @@ void ym2203_device::calculate_rates()
if (m_stream != nullptr)
m_stream->set_sample_rate(rate);
else
- m_stream = machine().sound().stream_alloc_legacy(*this,0,1,rate, stream_update_legacy_delegate(&ym2203_device::stream_generate,this));
+ m_stream = machine().sound().stream_alloc(*this,0,1,rate, stream_update_delegate(&ym2203_device::stream_generate,this), STREAM_DEFAULT_FLAGS);
}
//-------------------------------------------------
diff --git a/src/devices/sound/2203intf.h b/src/devices/sound/2203intf.h
index ccb5841cd82..df10125693a 100644
--- a/src/devices/sound/2203intf.h
+++ b/src/devices/sound/2203intf.h
@@ -39,7 +39,7 @@ protected:
virtual void device_clock_changed() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- void stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples);
+ void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
private:
enum
diff --git a/src/devices/sound/2608intf.cpp b/src/devices/sound/2608intf.cpp
index 4ca366fa117..b746ae15e66 100644
--- a/src/devices/sound/2608intf.cpp
+++ b/src/devices/sound/2608intf.cpp
@@ -63,12 +63,12 @@ void ym2608_device::timer_handler(int c,int count,int clock)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// stream_generate - handle a stream update
//-------------------------------------------------
-void ym2608_device::stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2608_device::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym2608_update_one(m_chip, outputs, samples);
+ ym2608_update_one(m_chip, outputs);
}
void ym2608_device::device_post_load()
@@ -93,7 +93,7 @@ void ym2608_device::device_start()
m_timer[1] = timer_alloc(1);
/* stream system initialize */
- m_stream = machine().sound().stream_alloc_legacy(*this,0,2,rate, stream_update_legacy_delegate(&ym2608_device::stream_generate,this));
+ m_stream = machine().sound().stream_alloc(*this,0,2,rate, stream_update_delegate(&ym2608_device::stream_generate,this), STREAM_DEFAULT_FLAGS);
/* initialize YM2608 */
m_chip = ym2608_init(this,clock(),rate,
diff --git a/src/devices/sound/2608intf.h b/src/devices/sound/2608intf.h
index c6a3fec6fc9..ca1361ba867 100644
--- a/src/devices/sound/2608intf.h
+++ b/src/devices/sound/2608intf.h
@@ -39,7 +39,7 @@ protected:
virtual void rom_bank_updated() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- void stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples);
+ void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
private:
void irq_handler(int irq);
diff --git a/src/devices/sound/2610intf.cpp b/src/devices/sound/2610intf.cpp
index 2f6e3e08620..b0ee9c99d32 100644
--- a/src/devices/sound/2610intf.cpp
+++ b/src/devices/sound/2610intf.cpp
@@ -62,20 +62,20 @@ void ym2610_device::timer_handler(int c,int count,int clock)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// stream_generate - handle a stream update
//-------------------------------------------------
-void ym2610_device::stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2610_device::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym2610_update_one(m_chip, outputs, samples);
+ ym2610_update_one(m_chip, outputs);
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// stream_generate - handle a stream update
//-------------------------------------------------
-void ym2610b_device::stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2610b_device::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym2610b_update_one(m_chip, outputs, samples);
+ ym2610b_update_one(m_chip, outputs);
}
@@ -102,7 +102,7 @@ void ym2610_device::device_start()
m_timer[1] = timer_alloc(1);
/* stream system initialize */
- m_stream = machine().sound().stream_alloc_legacy(*this,0,2,rate, stream_update_legacy_delegate(&ym2610_device::stream_generate,this));
+ m_stream = machine().sound().stream_alloc(*this,0,2,rate, stream_update_delegate(&ym2610_device::stream_generate,this), STREAM_DEFAULT_FLAGS);
if (!has_configured_map(0) && !has_configured_map(1))
{
diff --git a/src/devices/sound/2610intf.h b/src/devices/sound/2610intf.h
index a305f9d352d..9125feee4d6 100644
--- a/src/devices/sound/2610intf.h
+++ b/src/devices/sound/2610intf.h
@@ -40,7 +40,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples);
+ virtual void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
void * m_chip;
@@ -75,7 +75,7 @@ public:
ym2610b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
- virtual void stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override;
+ virtual void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
};
diff --git a/src/devices/sound/2612intf.cpp b/src/devices/sound/2612intf.cpp
index 679333cdcf3..b856ef33e65 100644
--- a/src/devices/sound/2612intf.cpp
+++ b/src/devices/sound/2612intf.cpp
@@ -56,12 +56,12 @@ void ym2612_device::timer_handler(int c,int count,int clock)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ym2612_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2612_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym2612_update_one(m_chip, outputs, samples, m_output_bits);
+ ym2612_update_one(m_chip, outputs, m_output_bits);
}
@@ -87,7 +87,7 @@ void ym2612_device::device_start()
m_timer[1] = timer_alloc(1);
/* stream system initialize */
- m_stream = stream_alloc_legacy(0,2,rate);
+ m_stream = stream_alloc(0,2,rate);
/**** initialize YM2612 ****/
m_chip = ym2612_init(this,clock(),rate,&ym2612_device::static_timer_handler,&ym2612_device::static_irq_handler);
@@ -108,7 +108,7 @@ void ym2612_device::calculate_rates()
if (m_stream != nullptr)
m_stream->set_sample_rate(rate);
else
- m_stream = stream_alloc_legacy(0,2,rate);
+ m_stream = stream_alloc(0,2,rate);
}
//-------------------------------------------------
diff --git a/src/devices/sound/2612intf.h b/src/devices/sound/2612intf.h
index f9447081d9b..c88b83ffef5 100644
--- a/src/devices/sound/2612intf.h
+++ b/src/devices/sound/2612intf.h
@@ -33,7 +33,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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;
u8 m_output_bits;
private:
diff --git a/src/devices/sound/262intf.cpp b/src/devices/sound/262intf.cpp
index 0a76cdf6d2b..616cefc6377 100644
--- a/src/devices/sound/262intf.cpp
+++ b/src/devices/sound/262intf.cpp
@@ -50,12 +50,12 @@ void ymf262_device::timer_handler(int c, const attotime &period)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ymf262_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ymf262_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ymf262_update_one(m_chip, outputs, samples);
+ ymf262_update_one(m_chip, outputs);
}
//-------------------------------------------------
@@ -81,7 +81,7 @@ void ymf262_device::device_start()
if (!m_chip)
throw emu_fatalerror("ymf262_device(%s): Error creating YMF262 chip", tag());
- m_stream = stream_alloc_legacy(0,4,rate);
+ m_stream = stream_alloc(0,4,rate);
/* YMF262 setup */
ymf262_set_timer_handler (m_chip, &ymf262_device::static_timer_handler, this);
diff --git a/src/devices/sound/262intf.h b/src/devices/sound/262intf.h
index 09ae497748d..6c2376fc960 100644
--- a/src/devices/sound/262intf.h
+++ b/src/devices/sound/262intf.h
@@ -27,7 +27,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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 irq_handler(int irq);
diff --git a/src/devices/sound/3526intf.cpp b/src/devices/sound/3526intf.cpp
index dce29c78440..906c3c3fd38 100644
--- a/src/devices/sound/3526intf.cpp
+++ b/src/devices/sound/3526intf.cpp
@@ -60,12 +60,12 @@ void ym3526_device::timer_handler(int c,const attotime &period)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ym3526_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym3526_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym3526_update_one(m_chip, outputs[0], samples);
+ ym3526_update_one(m_chip, outputs[0]);
}
@@ -109,7 +109,7 @@ void ym3526_device::calculate_rates()
if (m_stream != nullptr)
m_stream->set_sample_rate(rate);
else
- m_stream = stream_alloc_legacy(0,1,rate);
+ m_stream = stream_alloc(0,1,rate);
}
//-------------------------------------------------
diff --git a/src/devices/sound/3526intf.h b/src/devices/sound/3526intf.h
index 5b425f41241..a45825b57b5 100644
--- a/src/devices/sound/3526intf.h
+++ b/src/devices/sound/3526intf.h
@@ -32,7 +32,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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 irq_handler(int irq);
diff --git a/src/devices/sound/3812intf.cpp b/src/devices/sound/3812intf.cpp
index b9287f21d9e..c74c75e27b0 100644
--- a/src/devices/sound/3812intf.cpp
+++ b/src/devices/sound/3812intf.cpp
@@ -62,12 +62,12 @@ void ym3812_device::timer_handler(int c, const attotime &period)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ym3812_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym3812_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- ym3812_update_one(m_chip, outputs[0], samples);
+ ym3812_update_one(m_chip, outputs[0]);
}
//-------------------------------------------------
@@ -110,7 +110,7 @@ void ym3812_device::calculate_rates()
if (m_stream != nullptr)
m_stream->set_sample_rate(rate);
else
- m_stream = stream_alloc_legacy(0, 1, rate);
+ m_stream = stream_alloc(0, 1, rate);
}
//-------------------------------------------------
diff --git a/src/devices/sound/3812intf.h b/src/devices/sound/3812intf.h
index 46266bbbca2..5b2b4f9991a 100644
--- a/src/devices/sound/3812intf.h
+++ b/src/devices/sound/3812intf.h
@@ -30,7 +30,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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/sound/8950intf.cpp b/src/devices/sound/8950intf.cpp
index 63056582a0e..5eed79dd138 100644
--- a/src/devices/sound/8950intf.cpp
+++ b/src/devices/sound/8950intf.cpp
@@ -56,12 +56,12 @@ void y8950_device::timer_handler(int c, const attotime &period)
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void y8950_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void y8950_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- y8950_update_one(m_chip, outputs[0], samples);
+ y8950_update_one(m_chip, outputs[0]);
}
@@ -87,7 +87,7 @@ void y8950_device::device_start()
/* ADPCM ROM data */
y8950_set_delta_t_memory(m_chip, &y8950_device::static_read_byte, &y8950_device::static_write_byte);
- m_stream = stream_alloc_legacy(0,1,rate);
+ m_stream = stream_alloc(0,1,rate);
/* port and keyboard handler */
y8950_set_port_handler(m_chip, &y8950_device::static_port_handler_w, &y8950_device::static_port_handler_r, this);
y8950_set_keyboard_handler(m_chip, &y8950_device::static_keyboard_handler_w, &y8950_device::static_keyboard_handler_r, this);
diff --git a/src/devices/sound/8950intf.h b/src/devices/sound/8950intf.h
index d1ba497c08d..9ed70e7cd92 100644
--- a/src/devices/sound/8950intf.h
+++ b/src/devices/sound/8950intf.h
@@ -41,7 +41,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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 irq_handler(int irq);
diff --git a/src/devices/sound/fm.cpp b/src/devices/sound/fm.cpp
index 5679860a2f2..c36a95831c1 100644
--- a/src/devices/sound/fm.cpp
+++ b/src/devices/sound/fm.cpp
@@ -2111,12 +2111,12 @@ struct ym2203_state
} // anonymous namespace
/* Generate samples for one of the YM2203s */
-void ym2203_update_one(void *chip, FMSAMPLE *buffer, int length)
+void ym2203_update_one(void *chip, write_stream_view &buffer)
{
ym2203_state *F2203 = (ym2203_state *)chip;
FM_OPN *OPN = &F2203->OPN;
int i;
- FMSAMPLE *buf = buffer;
+ auto &buf = buffer;
FM_CH *cch[3];
cch[0] = &F2203->CH[0];
@@ -2147,7 +2147,7 @@ void ym2203_update_one(void *chip, FMSAMPLE *buffer, int length)
OPN->LFO_PM = 0;
/* buffering */
- for (i=0; i < length ; i++)
+ for (i=0; i < buf.samples() ; i++)
{
/* clear outputs */
OPN->out_fm[0] = 0;
@@ -2186,7 +2186,7 @@ void ym2203_update_one(void *chip, FMSAMPLE *buffer, int length)
#endif
/* buffering */
- buf[i] = lt;
+ buf.put_int(i, lt, 32768);
}
/* timer A control */
@@ -2727,19 +2727,18 @@ static inline void YM2608IRQMaskWrite(FM_OPN *OPN, ym2608_state *F2608, int v)
}
/* Generate samples for one of the YM2608s */
-void ym2608_update_one(void *chip, FMSAMPLE * const *buffer, int length)
+void ym2608_update_one(void *chip, std::vector<write_stream_view> &buffer)
{
ym2608_state *F2608 = (ym2608_state *)chip;
FM_OPN *OPN = &F2608->OPN;
YM_DELTAT *DELTAT = &F2608->deltaT;
int i,j;
- FMSAMPLE *bufL,*bufR;
FM_CH *cch[6];
int32_t *out_fm = OPN->out_fm;
/* set bufer */
- bufL = buffer[0];
- bufR = buffer[1];
+ auto &bufL = buffer[0];
+ auto &bufR = buffer[1];
cch[0] = &F2608->CH[0];
cch[1] = &F2608->CH[1];
@@ -2770,7 +2769,7 @@ void ym2608_update_one(void *chip, FMSAMPLE * const *buffer, int length)
/* buffering */
- for(i=0; i < length ; i++)
+ for(i=0; i < bufL.samples() ; i++)
{
advance_lfo(OPN);
@@ -2840,14 +2839,9 @@ void ym2608_update_one(void *chip, FMSAMPLE * const *buffer, int length)
lt += ((out_fm[5]>>1) & OPN->pan[10]);
rt += ((out_fm[5]>>1) & OPN->pan[11]);
- lt >>= FINAL_SH;
- rt >>= FINAL_SH;
-
- Limit( lt, MAXOUT, MINOUT );
- Limit( rt, MAXOUT, MINOUT );
/* buffering */
- bufL[i] = lt;
- bufR[i] = rt;
+ bufL.put_int_clamp(i, lt, 32768 << FINAL_SH);
+ bufR.put_int_clamp(i, rt, 32768 << FINAL_SH);
#ifdef SAVE_SAMPLE
SAVE_ALL_CHANNELS
@@ -3275,19 +3269,18 @@ int ym2608_timer_over(void *chip,int c)
/* YM2610(OPNB) */
/* Generate samples for one of the YM2610s */
-void ym2610_update_one(void *chip, FMSAMPLE * const *buffer, int length)
+void ym2610_update_one(void *chip, std::vector<write_stream_view> &buffer)
{
ym2610_state *F2610 = (ym2610_state *)chip;
FM_OPN *OPN = &F2610->OPN;
YM_DELTAT *DELTAT = &F2610->deltaT;
int i,j;
- FMSAMPLE *bufL,*bufR;
FM_CH *cch[4];
int32_t *out_fm = OPN->out_fm;
/* buffer setup */
- bufL = buffer[0];
- bufR = buffer[1];
+ auto &bufL = buffer[0];
+ auto &bufR = buffer[1];
cch[0] = &F2610->CH[1];
cch[1] = &F2610->CH[2];
@@ -3323,7 +3316,7 @@ void ym2610_update_one(void *chip, FMSAMPLE * const *buffer, int length)
refresh_fc_eg_chan( OPN, cch[3] );
/* buffering */
- for(i=0; i < length ; i++)
+ for(i=0; i < bufL.samples() ; i++)
{
advance_lfo(OPN);
@@ -3386,20 +3379,13 @@ void ym2610_update_one(void *chip, FMSAMPLE * const *buffer, int length)
lt += ((out_fm[5]>>1) & OPN->pan[10]);
rt += ((out_fm[5]>>1) & OPN->pan[11]);
-
- lt >>= FINAL_SH;
- rt >>= FINAL_SH;
-
- Limit( lt, MAXOUT, MINOUT );
- Limit( rt, MAXOUT, MINOUT );
-
#ifdef SAVE_SAMPLE
SAVE_ALL_CHANNELS
#endif
/* buffering */
- bufL[i] = lt;
- bufR[i] = rt;
+ bufL.put_int_clamp(i, lt, 32768 << FINAL_SH);
+ bufR.put_int_clamp(i, rt, 32768 << FINAL_SH);
}
/* timer A control */
@@ -3411,19 +3397,18 @@ void ym2610_update_one(void *chip, FMSAMPLE * const *buffer, int length)
#if BUILD_YM2610B
/* Generate samples for one of the YM2610Bs */
-void ym2610b_update_one(void *chip, FMSAMPLE * const *buffer, int length)
+void ym2610b_update_one(void *chip, std::vector<write_stream_view> &buffer)
{
ym2610_state *F2610 = (ym2610_state *)chip;
FM_OPN *OPN = &F2610->OPN;
YM_DELTAT *DELTAT = &F2610->deltaT;
int i,j;
- FMSAMPLE *bufL,*bufR;
FM_CH *cch[6];
int32_t *out_fm = OPN->out_fm;
/* buffer setup */
- bufL = buffer[0];
- bufR = buffer[1];
+ auto &bufL = buffer[0];
+ auto &bufR = buffer[1];
cch[0] = &F2610->CH[0];
cch[1] = &F2610->CH[1];
@@ -3453,7 +3438,7 @@ void ym2610b_update_one(void *chip, FMSAMPLE * const *buffer, int length)
refresh_fc_eg_chan( OPN, cch[5] );
/* buffering */
- for(i=0; i < length ; i++)
+ for(i=0; i < bufL.samples() ; i++)
{
advance_lfo(OPN);
@@ -3524,20 +3509,13 @@ void ym2610b_update_one(void *chip, FMSAMPLE * const *buffer, int length)
lt += ((out_fm[5]>>1) & OPN->pan[10]);
rt += ((out_fm[5]>>1) & OPN->pan[11]);
-
- lt >>= FINAL_SH;
- rt >>= FINAL_SH;
-
- Limit( lt, MAXOUT, MINOUT );
- Limit( rt, MAXOUT, MINOUT );
-
#ifdef SAVE_SAMPLE
SAVE_ALL_CHANNELS
#endif
/* buffering */
- bufL[i] = lt;
- bufR[i] = rt;
+ bufL.put_int_clamp(i, lt, 32768);
+ bufR.put_int_clamp(i, rt, 32768);
}
/* timer A control */
diff --git a/src/devices/sound/fm.h b/src/devices/sound/fm.h
index d5d8760a449..32f768a824b 100644
--- a/src/devices/sound/fm.h
+++ b/src/devices/sound/fm.h
@@ -108,7 +108,7 @@ void ym2203_reset_chip(void *chip);
/*
** update one of chip
*/
-void ym2203_update_one(void *chip, FMSAMPLE *buffer, int length);
+void ym2203_update_one(void *chip, write_stream_view &buffer);
/*
** Write
@@ -142,7 +142,7 @@ void * ym2608_init(device_t *device, int baseclock, int rate,
void ym2608_clock_changed(void *chip, int clock, int rate);
void ym2608_shutdown(void *chip);
void ym2608_reset_chip(void *chip);
-void ym2608_update_one(void *chip, FMSAMPLE * const *buffer, int length);
+void ym2608_update_one(void *chip, std::vector<write_stream_view> &buffer);
int ym2608_write(void *chip, int a,unsigned char v);
unsigned char ym2608_read(void *chip,int a);
@@ -158,10 +158,10 @@ void * ym2610_init(device_t *device, int baseclock, int rate,
void ym2610_clock_changed(void *chip, int clock, int rate);
void ym2610_shutdown(void *chip);
void ym2610_reset_chip(void *chip);
-void ym2610_update_one(void *chip, FMSAMPLE * const *buffer, int length);
+void ym2610_update_one(void *chip, std::vector<write_stream_view> &buffer);
#if BUILD_YM2610B
-void ym2610b_update_one(void *chip, FMSAMPLE * const *buffer, int length);
+void ym2610b_update_one(void *chip, std::vector<write_stream_view> &buffer);
#endif /* BUILD_YM2610B */
int ym2610_write(void *chip, int a,unsigned char v);
@@ -176,7 +176,7 @@ void * ym2612_init(device_t *device, int baseclock, int rate,
void ym2612_clock_changed(void *chip, int clock, int rate);
void ym2612_shutdown(void *chip);
void ym2612_reset_chip(void *chip);
-void ym2612_update_one(void *chip, FMSAMPLE * const *buffer, int length, u8 output_bits);
+void ym2612_update_one(void *chip, std::vector<write_stream_view> &buffer, u8 output_bits);
int ym2612_write(void *chip, int a,unsigned char v);
unsigned char ym2612_read(void *chip,int a);
diff --git a/src/devices/sound/fm2612.cpp b/src/devices/sound/fm2612.cpp
index b3482d0ac72..4f905bf80f1 100644
--- a/src/devices/sound/fm2612.cpp
+++ b/src/devices/sound/fm2612.cpp
@@ -2174,7 +2174,7 @@ static void init_tables(void)
/*******************************************************************************/
/* Generate samples for one of the YM2612s */
-void ym2612_update_one(void *chip, FMSAMPLE * const *buffer, int length, u8 output_bits)
+void ym2612_update_one(void *chip, std::vector<write_stream_view> &buffer, u8 output_bits)
{
// TODO : 'ladder' effects for Mega Drive/Genesis
const u8 output_shift = (output_bits > 14) ? 0 : (14 - output_bits);
@@ -2183,13 +2183,12 @@ void ym2612_update_one(void *chip, FMSAMPLE * const *buffer, int length, u8 outp
fm2612_FM_OPN *OPN = &F2612->OPN;
int32_t *out_fm = OPN->out_fm;
int i;
- FMSAMPLE *bufL,*bufR;
fm2612_FM_CH *cch[6];
int lt,rt;
/* set bufer */
- bufL = buffer[0];
- bufR = buffer[1];
+ auto &bufL = buffer[0];
+ auto &bufR = buffer[1];
cch[0] = &F2612->CH[0];
cch[1] = &F2612->CH[1];
@@ -2220,7 +2219,7 @@ void ym2612_update_one(void *chip, FMSAMPLE * const *buffer, int length, u8 outp
refresh_fc_eg_chan( OPN, cch[5] );
/* buffering */
- for(i=0; i < length ; i++)
+ for(i=0; i < bufL.samples() ; i++)
{
/* clear outputs */
out_fm[0] = 0;
@@ -2302,8 +2301,8 @@ void ym2612_update_one(void *chip, FMSAMPLE * const *buffer, int length, u8 outp
#endif
/* buffering */
- bufL[i] = lt;
- bufR[i] = rt;
+ bufL.put_int(i, lt, 32768);
+ bufR.put_int(i, rt, 32768);
/* CSM mode: if CSM Key ON has occurred, CSM Key OFF need to be sent */
/* only if Timer A does not overflow again (i.e CSM Key ON not set again) */
diff --git a/src/devices/sound/fmopl.cpp b/src/devices/sound/fmopl.cpp
index 99139310d69..f843d781d42 100644
--- a/src/devices/sound/fmopl.cpp
+++ b/src/devices/sound/fmopl.cpp
@@ -2206,14 +2206,14 @@ void ym3812_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandler,device
** '*buffer' is the output buffer pointer
** 'length' is the number of samples that should be generated
*/
-void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
+void ym3812_update_one(void *chip, write_stream_view &buffer)
{
FM_OPL *OPL = (FM_OPL *)chip;
uint8_t rhythm = OPL->rhythm&0x20;
- OPLSAMPLE *buf = buffer;
+ auto &buf = buffer;
int i;
- for( i=0; i < length ; i++ )
+ for( i=0; i < buf.samples(); i++ )
{
int lt;
@@ -2242,11 +2242,6 @@ void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
lt = OPL->output[0];
- lt >>= FINAL_SH;
-
- /* limit check */
- lt = limit( lt , MAXOUT, MINOUT );
-
#ifdef SAVE_SAMPLE
if (which==0)
{
@@ -2255,7 +2250,7 @@ void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
#endif
/* store to sound buffer */
- buf[i] = lt;
+ buf.put_int_clamp(i, lt, 32768 << FINAL_SH);
OPL->advance();
}
@@ -2335,14 +2330,14 @@ void ym3526_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandler,device
** '*buffer' is the output buffer pointer
** 'length' is the number of samples that should be generated
*/
-void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length)
+void ym3526_update_one(void *chip, write_stream_view &buffer)
{
FM_OPL *OPL = (FM_OPL *)chip;
uint8_t rhythm = OPL->rhythm&0x20;
- OPLSAMPLE *buf = buffer;
+ auto &buf = buffer;
int i;
- for( i=0; i < length ; i++ )
+ for( i=0; i < buf.samples() ; i++ )
{
int lt;
@@ -2371,11 +2366,6 @@ void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length)
lt = OPL->output[0];
- lt >>= FINAL_SH;
-
- /* limit check */
- lt = limit( lt , MAXOUT, MINOUT );
-
#ifdef SAVE_SAMPLE
if (which==0)
{
@@ -2384,7 +2374,7 @@ void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length)
#endif
/* store to sound buffer */
- buf[i] = lt;
+ buf.put_int_clamp(i, lt, 32768 << FINAL_SH);
OPL->advance();
}
@@ -2491,15 +2481,15 @@ void y8950_set_delta_t_memory(void *chip, FM_READBYTE read_byte, FM_WRITEBYTE wr
** '*buffer' is the output buffer pointer
** 'length' is the number of samples that should be generated
*/
-void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
+void y8950_update_one(void *chip, write_stream_view &buffer)
{
int i;
FM_OPL *OPL = (FM_OPL *)chip;
uint8_t rhythm = OPL->rhythm&0x20;
YM_DELTAT &DELTAT = *OPL->deltat;
- OPLSAMPLE *buf = buffer;
+ auto &buf = buffer;
- for( i=0; i < length ; i++ )
+ for( i=0; i < buf.samples() ; i++ )
{
int lt;
@@ -2533,11 +2523,6 @@ void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
lt = OPL->output[0] + (OPL->output_deltat[0]>>11);
- lt >>= FINAL_SH;
-
- /* limit check */
- lt = limit( lt , MAXOUT, MINOUT );
-
#ifdef SAVE_SAMPLE
if (which==0)
{
@@ -2546,7 +2531,7 @@ void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
#endif
/* store to sound buffer */
- buf[i] = lt;
+ buf.put_int_clamp(i, lt, 32768 << FINAL_SH);
OPL->advance();
}
diff --git a/src/devices/sound/fmopl.h b/src/devices/sound/fmopl.h
index add973a2369..b70c46f93e3 100644
--- a/src/devices/sound/fmopl.h
+++ b/src/devices/sound/fmopl.h
@@ -44,7 +44,7 @@ void ym3812_reset_chip(void *chip);
int ym3812_write(void *chip, int a, int v);
unsigned char ym3812_read(void *chip, int a);
int ym3812_timer_over(void *chip, int c);
-void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length);
+void ym3812_update_one(void *chip, write_stream_view &buffer);
void ym3812_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
void ym3812_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
@@ -77,7 +77,7 @@ int ym3526_timer_over(void *chip, int c);
** '*buffer' is the output buffer pointer
** 'length' is the number of samples that should be generated
*/
-void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length);
+void ym3526_update_one(void *chip, write_stream_view &buffer);
void ym3526_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
void ym3526_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
@@ -100,7 +100,7 @@ void y8950_reset_chip(void *chip);
int y8950_write(void *chip, int a, int v);
unsigned char y8950_read (void *chip, int a);
int y8950_timer_over(void *chip, int c);
-void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length);
+void y8950_update_one(void *chip, write_stream_view &buffer);
void y8950_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
void y8950_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
diff --git a/src/devices/sound/ym2413.cpp b/src/devices/sound/ym2413.cpp
index ca4a9acb874..28cf77c097b 100644
--- a/src/devices/sound/ym2413.cpp
+++ b/src/devices/sound/ym2413.cpp
@@ -1470,12 +1470,12 @@ void ym2413_device::write_reg(int r, int v)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ym2413_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ym2413_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++ )
{
output[0] = 0;
output[1] = 0;
@@ -1496,8 +1496,8 @@ void ym2413_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
rhythm_calc(&P_CH[0], noise_rng & 1 );
}
- outputs[0][i] = limit( output[0] , 32767, -32768 );
- outputs[1][i] = limit( output[1] , 32767, -32768 );
+ outputs[0].put_int_clamp(i, output[0], 32768);
+ outputs[1].put_int_clamp(i, output[1], 32768);
advance();
}
@@ -1511,7 +1511,7 @@ void ym2413_device::device_start()
{
int rate = clock()/72;
- m_stream = stream_alloc_legacy(0,2,rate);
+ m_stream = stream_alloc(0,2,rate);
for (int x=0; x<TL_RES_LEN; x++)
{
diff --git a/src/devices/sound/ym2413.h b/src/devices/sound/ym2413.h
index 2e1db357150..27174977332 100644
--- a/src/devices/sound/ym2413.h
+++ b/src/devices/sound/ym2413.h
@@ -25,7 +25,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;
uint8_t m_inst_table[19][8];
diff --git a/src/devices/sound/ymf262.cpp b/src/devices/sound/ymf262.cpp
index 6ec8e081021..857203a24ec 100644
--- a/src/devices/sound/ymf262.cpp
+++ b/src/devices/sound/ymf262.cpp
@@ -2618,19 +2618,19 @@ void ymf262_set_update_handler(void *chip, OPL3_UPDATEHANDLER UpdateHandler, dev
** '**buffers' is table of 4 pointers to the buffers: CH.A, CH.B, CH.C and CH.D
** 'length' is the number of samples that should be generated
*/
-void ymf262_update_one(void *_chip, OPL3SAMPLE * const *buffers, int length)
+void ymf262_update_one(void *_chip, std::vector<write_stream_view> &buffers)
{
int i;
OPL3 *chip = (OPL3 *)_chip;
signed int *chanout = chip->chanout;
uint8_t rhythm = chip->rhythm&0x20;
- OPL3SAMPLE *ch_a = buffers[0]; // DO2 (mixed) left output for OPL4
- OPL3SAMPLE *ch_b = buffers[1]; // DO2 (mixed) right output for OPL4
- OPL3SAMPLE *ch_c = buffers[2]; // DO0 (FM only) left output for OPL4
- OPL3SAMPLE *ch_d = buffers[3]; // DO0 (FM only) right output for OPL4
+ auto &ch_a = buffers[0]; // DO2 (mixed) left output for OPL4
+ auto &ch_b = buffers[1]; // DO2 (mixed) right output for OPL4
+ auto &ch_c = buffers[2]; // DO0 (FM only) left output for OPL4
+ auto &ch_d = buffers[3]; // DO0 (FM only) right output for OPL4
- for( i=0; i < length ; i++ )
+ for( i=0; i < ch_a.samples() ; i++ )
{
int a,b,c,d;
@@ -2782,16 +2782,6 @@ void ymf262_update_one(void *_chip, OPL3SAMPLE * const *buffers, int length)
c += chanout[17] & chip->pan[70];
d += chanout[17] & chip->pan[71];
#endif
- a >>= FINAL_SH;
- b >>= FINAL_SH;
- c >>= FINAL_SH;
- d >>= FINAL_SH;
-
- /* limit check */
- a = limit( a , MAXOUT, MINOUT );
- b = limit( b , MAXOUT, MINOUT );
- c = limit( c , MAXOUT, MINOUT );
- d = limit( d , MAXOUT, MINOUT );
#ifdef SAVE_SAMPLE
if (which==0)
@@ -2801,10 +2791,10 @@ void ymf262_update_one(void *_chip, OPL3SAMPLE * const *buffers, int length)
#endif
/* store to sound buffer */
- ch_a[i] = a;
- ch_b[i] = b;
- ch_c[i] = c;
- ch_d[i] = d;
+ ch_a.put_int_clamp(i, a, 32768 << FINAL_SH);
+ ch_b.put_int_clamp(i, a, 32768 << FINAL_SH);
+ ch_c.put_int_clamp(i, a, 32768 << FINAL_SH);
+ ch_d.put_int_clamp(i, a, 32768 << FINAL_SH);
advance(chip);
}
diff --git a/src/devices/sound/ymf262.h b/src/devices/sound/ymf262.h
index d459a9a68ee..3c02e0da16c 100644
--- a/src/devices/sound/ymf262.h
+++ b/src/devices/sound/ymf262.h
@@ -33,7 +33,7 @@ void ymf262_reset_chip(void *chip);
int ymf262_write(void *chip, int a, int v);
unsigned char ymf262_read(void *chip, int a);
int ymf262_timer_over(void *chip, int c);
-void ymf262_update_one(void *chip, OPL3SAMPLE * const *buffers, int length);
+void ymf262_update_one(void *chip, std::vector<write_stream_view> &buffers);
void ymf262_set_timer_handler(void *chip, OPL3_TIMERHANDLER TimerHandler, device_t *device);
void ymf262_set_irq_handler(void *chip, OPL3_IRQHANDLER IRQHandler, device_t *device);
diff --git a/src/devices/sound/ymf271.cpp b/src/devices/sound/ymf271.cpp
index 03ca33a2382..482f985dd96 100644
--- a/src/devices/sound/ymf271.cpp
+++ b/src/devices/sound/ymf271.cpp
@@ -563,10 +563,10 @@ void ymf271_device::set_feedback(int slotnum, int64_t inp)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ymf271_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int i, j;
int op;
@@ -599,7 +599,7 @@ void ymf271_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
if (m_slots[slot1].active)
{
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
int64_t output1 = 0, output2 = 0, output3 = 0, output4 = 0;
int64_t phase_mod1, phase_mod2, phase_mod3;
@@ -833,7 +833,7 @@ void ymf271_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
mixp = &m_mix_buffer[0];
if (m_slots[slot1].active)
{
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
int64_t output1 = 0, output3 = 0;
int64_t phase_mod1, phase_mod3;
@@ -900,7 +900,7 @@ void ymf271_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
if (m_slots[slot1].active)
{
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
int64_t output1 = 0, output2 = 0, output3 = 0;
int64_t phase_mod1, phase_mod3;
@@ -1006,29 +1006,29 @@ void ymf271_device::sound_stream_update_legacy(sound_stream &stream, stream_samp
}
mixp = &m_mix_buffer[0];
- update_pcm(j + (3*12), mixp, samples);
+ update_pcm(j + (3*12), mixp, outputs[0].samples());
break;
}
// PCM
case 3:
{
- update_pcm(j + (0*12), mixp, samples);
- update_pcm(j + (1*12), mixp, samples);
- update_pcm(j + (2*12), mixp, samples);
- update_pcm(j + (3*12), mixp, samples);
+ update_pcm(j + (0*12), mixp, outputs[0].samples());
+ update_pcm(j + (1*12), mixp, outputs[0].samples());
+ update_pcm(j + (2*12), mixp, outputs[0].samples());
+ update_pcm(j + (3*12), mixp, outputs[0].samples());
break;
}
}
}
mixp = &m_mix_buffer[0];
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
- outputs[0][i] = (*mixp++)>>2;
- outputs[1][i] = (*mixp++)>>2;
- outputs[2][i] = (*mixp++)>>2;
- outputs[3][i] = (*mixp++)>>2;
+ outputs[0].put_int(i, *mixp++, 32768 << 2);
+ outputs[1].put_int(i, *mixp++, 32768 << 2);
+ outputs[2].put_int(i, *mixp++, 32768 << 2);
+ outputs[3].put_int(i, *mixp++, 32768 << 2);
}
}
@@ -1748,7 +1748,7 @@ void ymf271_device::device_start()
init_state();
m_mix_buffer.resize(m_master_clock/(384/4));
- m_stream = stream_alloc_legacy(0, 4, m_master_clock/384);
+ m_stream = stream_alloc(0, 4, m_master_clock/384);
}
//-------------------------------------------------
diff --git a/src/devices/sound/ymf271.h b/src/devices/sound/ymf271.h
index 87f06eb8e73..1c628f34cf1 100644
--- a/src/devices/sound/ymf271.h
+++ b/src/devices/sound/ymf271.h
@@ -28,7 +28,7 @@ protected:
virtual void device_clock_changed() 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;
// device_rom_interface overrides
virtual void rom_bank_updated() override;
diff --git a/src/devices/sound/ymf278b.cpp b/src/devices/sound/ymf278b.cpp
index 7bda7b6b8ef..f9f308a4892 100644
--- a/src/devices/sound/ymf278b.cpp
+++ b/src/devices/sound/ymf278b.cpp
@@ -212,10 +212,10 @@ void ymf278b_device::compute_envelope(YMF278BSlot *slot)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ymf278b_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ymf278b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int i, j;
YMF278BSlot *slot;
@@ -223,14 +223,14 @@ void ymf278b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
int32_t *mixp;
int32_t vl, vr;
- ymf262_update_one(m_ymf262, outputs, samples);
- vl = m_mix_level[m_fm_l];
- vr = m_mix_level[m_fm_r];
- for (i = 0; i < samples; i++)
+ ymf262_update_one(m_ymf262, outputs);
+ stream_buffer::sample_t fvl = stream_buffer::sample_t(m_mix_level[m_fm_l]) * (1.0 / 65536.0);
+ stream_buffer::sample_t fvr = stream_buffer::sample_t(m_mix_level[m_fm_r]) * (1.0 / 65536.0);
+ for (i = 0; i < outputs[0].samples(); i++)
{
// DO2 mixing
- outputs[0][i] = (outputs[0][i] * vl) >> 16;
- outputs[1][i] = (outputs[1][i] * vr) >> 16;
+ outputs[0].put(i, outputs[0].get(i) * fvl);
+ outputs[1].put(i, outputs[1].get(i) * fvr);
}
std::fill(m_mix_buffer.begin(), m_mix_buffer.end(), 0);
@@ -243,7 +243,7 @@ void ymf278b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
{
mixp = &m_mix_buffer[0];
- for (j = 0; j < samples; j++)
+ for (j = 0; j < outputs[0].samples(); j++)
{
if (slot->stepptr >= slot->endaddr)
{
@@ -316,12 +316,12 @@ void ymf278b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
mixp = &m_mix_buffer[0];
vl = m_mix_level[m_pcm_l];
vr = m_mix_level[m_pcm_r];
- for (i = 0; i < samples; i++)
+ for (i = 0; i < outputs[0].samples(); i++)
{
- outputs[0][i] += (*mixp++ * vl) >> 16;
- outputs[1][i] += (*mixp++ * vr) >> 16;
- outputs[4][i] = *mixp++;
- outputs[5][i] = *mixp++;
+ outputs[0].add_int(i, (*mixp++ * vl) >> 16, 32768);
+ outputs[1].add_int(i, (*mixp++ * vr) >> 16, 32768);
+ outputs[4].put_int(i, *mixp++, 32768);
+ outputs[5].put_int(i, *mixp++, 32768);
}
}
@@ -1009,7 +1009,7 @@ void ymf278b_device::device_start()
m_slots[i].num = i;
}
- m_stream = stream_alloc_legacy(0, 6, m_rate);
+ m_stream = stream_alloc(0, 6, m_rate);
m_mix_buffer.resize(m_rate*4,0);
// rate tables
diff --git a/src/devices/sound/ymf278b.h b/src/devices/sound/ymf278b.h
index 03fa9880442..d872ce13e38 100644
--- a/src/devices/sound/ymf278b.h
+++ b/src/devices/sound/ymf278b.h
@@ -29,7 +29,7 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) 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;
// device_rom_interface overrides
virtual void rom_bank_updated() override;
diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp
index 94ef134bd4c..b2836c74967 100644
--- a/src/devices/sound/ymz280b.cpp
+++ b/src/devices/sound/ymz280b.cpp
@@ -412,18 +412,18 @@ int ymz280b_device::generate_pcm16(struct YMZ280BVoice *voice, s16 *buffer, int
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void ymz280b_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *lacc = outputs[0];
- stream_sample_t *racc = outputs[1];
+ auto &lacc = outputs[0];
+ auto &racc = outputs[1];
int v;
/* clear out the accumulator */
- memset(lacc, 0, samples * sizeof(lacc[0]));
- memset(racc, 0, samples * sizeof(racc[0]));
+ lacc.fill(0);
+ racc.fill(0);
/* loop over voices */
for (v = 0; v < 8; v++)
@@ -432,11 +432,10 @@ void ymz280b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
s16 prev = voice->last_sample;
s16 curr = voice->curr_sample;
s16 *curr_data = m_scratch.get();
- s32 *ldest = lacc;
- s32 *rdest = racc;
+ s32 sampindex = 0;
u32 new_samples, samples_left;
u32 final_pos;
- int remaining = samples;
+ int remaining = lacc.samples();
int lvol = voice->output_left;
int rvol = voice->output_right;
@@ -453,8 +452,9 @@ void ymz280b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
while (remaining > 0 && voice->output_pos < FRAC_ONE)
{
int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS;
- *ldest++ += interp_sample * lvol;
- *rdest++ += interp_sample * rvol;
+ lacc.add_int(sampindex, interp_sample * lvol, 32768 * 256);
+ racc.add_int(sampindex, interp_sample * rvol, 32768 * 256);
+ sampindex++;
voice->output_pos += voice->output_step;
remaining--;
}
@@ -517,8 +517,9 @@ void ymz280b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
while (remaining > 0 && voice->output_pos < FRAC_ONE)
{
int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS;
- *ldest++ += interp_sample * lvol;
- *rdest++ += interp_sample * rvol;
+ lacc.add_int(sampindex, interp_sample * lvol, 32768 * 256);
+ racc.add_int(sampindex, interp_sample * rvol, 32768 * 256);
+ sampindex++;
voice->output_pos += voice->output_step;
remaining--;
}
@@ -536,12 +537,6 @@ void ymz280b_device::sound_stream_update_legacy(sound_stream &stream, stream_sam
voice->last_sample = prev;
voice->curr_sample = curr;
}
-
- for (v = 0; v < samples; v++)
- {
- outputs[0][v] /= 256;
- outputs[1][v] /= 256;
- }
}
@@ -565,7 +560,7 @@ void ymz280b_device::device_start()
}
/* create the stream */
- m_stream = stream_alloc_legacy(0, 2, INTERNAL_SAMPLE_RATE);
+ m_stream = stream_alloc(0, 2, INTERNAL_SAMPLE_RATE);
/* allocate memory */
assert(MAX_SAMPLE_CHUNK < 0x10000);
diff --git a/src/devices/sound/ymz280b.h b/src/devices/sound/ymz280b.h
index ccbcb393bd8..5da3ea46cc3 100644
--- a/src/devices/sound/ymz280b.h
+++ b/src/devices/sound/ymz280b.h
@@ -36,7 +36,7 @@ protected:
virtual void device_clock_changed() 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;
// device_rom_interface overrides
virtual void rom_bank_updated() override;
diff --git a/src/devices/sound/ymz770.cpp b/src/devices/sound/ymz770.cpp
index 3934c6ac6dd..9d489d8a89d 100644
--- a/src/devices/sound/ymz770.cpp
+++ b/src/devices/sound/ymz770.cpp
@@ -77,7 +77,7 @@ ymz770_device::ymz770_device(const machine_config &mconfig, device_type type, co
void ymz770_device::device_start()
{
// create the stream
- m_stream = stream_alloc_legacy(0, 2, m_sclock);
+ m_stream = stream_alloc(0, 2, m_sclock);
for (auto & channel : m_channels)
{
@@ -178,18 +178,16 @@ void ymz770_device::device_reset()
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void ymz770_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void ymz770_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;
+ auto &outL = outputs[0];
+ auto &outR = outputs[1];
- outL = outputs[0];
- outR = outputs[1];
-
- for (int i = 0; i < samples; i++)
+ for (int i = 0; i < outL.samples(); i++)
{
sequencer();
@@ -282,8 +280,8 @@ retry:
}
if (m_mute)
mixr = mixl = 0;
- outL[i] = mixl;
- outR[i] = mixr;
+ outL.put_int(i, mixl, 32768);
+ outR.put_int(i, mixr, 32768);
}
}
diff --git a/src/devices/sound/ymz770.h b/src/devices/sound/ymz770.h
index ade24f61501..6c87cef8de4 100644
--- a/src/devices/sound/ymz770.h
+++ b/src/devices/sound/ymz770.h
@@ -33,7 +33,7 @@ protected:
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;
virtual void internal_reg_write(uint8_t reg, uint8_t data);
virtual uint32_t get_phrase_offs(int phrase) { return m_rom[(4 * phrase) + 1] << 16 | m_rom[(4 * phrase) + 2] << 8 | m_rom[(4 * phrase) + 3]; };
diff --git a/src/devices/sound/zsg2.cpp b/src/devices/sound/zsg2.cpp
index b964bce5f14..2fa01cfb3a5 100644
--- a/src/devices/sound/zsg2.cpp
+++ b/src/devices/sound/zsg2.cpp
@@ -134,7 +134,7 @@ void zsg2_device::device_start()
memset(&m_chan, 0, sizeof(m_chan));
- m_stream = stream_alloc_legacy(0, 4, clock() / 768);
+ m_stream = stream_alloc(0, 4, clock() / 768);
m_mem_blocks = m_mem_base.length();
m_mem_copy = make_unique_clear<uint32_t[]>(m_mem_blocks);
@@ -280,12 +280,12 @@ void zsg2_device::filter_samples(zchan *ch)
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void zsg2_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void zsg2_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++)
{
int32_t mix[4] = {};
@@ -355,8 +355,7 @@ void zsg2_device::sound_stream_update_legacy(sound_stream &stream, stream_sample
}
for(int output=0; output<4; output++)
- outputs[output][i] = std::min<int32_t>(std::max<int32_t>(mix[output], -32768), 32767);
-
+ outputs[output].put_int_clamp(i, mix[output], 32768);
}
m_sample_count++;
}
diff --git a/src/devices/sound/zsg2.h b/src/devices/sound/zsg2.h
index 592cbf83787..0239f6ff03d 100644
--- a/src/devices/sound/zsg2.h
+++ b/src/devices/sound/zsg2.h
@@ -29,7 +29,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:
const uint16_t STATUS_ACTIVE = 0x8000;