summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-16 18:11:02 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-16 18:11:30 -0700
commit937bb188b2ff6f09c11976dcd8dc858ae928e469 (patch)
tree55e70faa2ddbc58a32fe6fb3c45231bd3ac2703f /src/devices
parent279284e3c334d91d17b02fe35fc9495b4904b5fa (diff)
dac76/dave/digitalk/discrete: update to new stream callbacks
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/sound/dac76.cpp13
-rw-r--r--src/devices/sound/dac76.h2
-rw-r--r--src/devices/sound/dave.cpp24
-rw-r--r--src/devices/sound/dave.h2
-rw-r--r--src/devices/sound/digitalk.cpp30
-rw-r--r--src/devices/sound/digitalk.h2
-rw-r--r--src/devices/sound/disc_cls.h12
-rw-r--r--src/devices/sound/disc_inp.hxx20
-rw-r--r--src/devices/sound/discrete.cpp12
-rw-r--r--src/devices/sound/discrete.h4
10 files changed, 56 insertions, 65 deletions
diff --git a/src/devices/sound/dac76.cpp b/src/devices/sound/dac76.cpp
index 9a8b57ead04..bbeb5728577 100644
--- a/src/devices/sound/dac76.cpp
+++ b/src/devices/sound/dac76.cpp
@@ -51,7 +51,7 @@ dac76_device::dac76_device(const machine_config &mconfig, const char *tag, devic
void dac76_device::device_start()
{
// create sound stream
- m_stream = stream_alloc_legacy(0, 1, machine().sample_rate() * 8);
+ m_stream = stream_alloc(0, 1, machine().sample_rate() * 8);
// register for save states
save_item(NAME(m_chord));
@@ -71,11 +71,11 @@ void dac76_device::device_reset()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle update requests for
+// sound_stream_update - handle update requests for
// our sound stream
//-------------------------------------------------
-void dac76_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
// get current output level
int step_size = (2 << m_chord);
@@ -84,9 +84,6 @@ void dac76_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl
// apply sign bit
vout *= (m_sb ? +1 : -1);
- // range is 0-8031, normalize to about 0-32768 range
- vout *= 4;
-
- for (int i = 0; i < samples; i++)
- outputs[0][i] = vout;
+ // range is 0-8031, normalize to 0-1 range
+ outputs[0].fill(stream_buffer::sample_t(vout) * (1.0 / 8031.0));
}
diff --git a/src/devices/sound/dac76.h b/src/devices/sound/dac76.h
index 521a432baf6..74f51690082 100644
--- a/src/devices/sound/dac76.h
+++ b/src/devices/sound/dac76.h
@@ -57,7 +57,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;
private:
static constexpr int m_level[8] = { 0, 33, 99, 231, 495, 1023, 2079, 4191 };
diff --git a/src/devices/sound/dave.cpp b/src/devices/sound/dave.cpp
index f722afb97bc..f26ea891879 100644
--- a/src/devices/sound/dave.cpp
+++ b/src/devices/sound/dave.cpp
@@ -122,7 +122,7 @@ void dave_device::device_start()
the volumes are mixed internally and output as left and right volume */
/* 3 tone channels + 1 noise channel */
- m_sound_stream_var = stream_alloc_legacy(0, 2, machine().sample_rate());
+ m_sound_stream_var = stream_alloc(0, 2, machine().sample_rate());
}
@@ -187,12 +187,11 @@ device_memory_interface::space_config_vector dave_device::memory_space_config()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void dave_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *buffer1, *buffer2;
/* 0 = channel 0 left volume, 1 = channel 0 right volume,
2 = channel 1 left volume, 3 = channel 1 right volume,
4 = channel 2 left volume, 5 = channel 2 right volume
@@ -203,10 +202,11 @@ void dave_device::sound_stream_update_legacy(sound_stream &stream, stream_sample
//logerror("sound update!\n");
- buffer1 = outputs[0];
- buffer2 = outputs[1];
+ auto &buffer1 = outputs[0];
+ auto &buffer2 = outputs[1];
- while (samples)
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / (4.0 * 32768.0);
+ for (int sampindex = 0; sampindex < buffer1.samples(); sampindex++)
{
int vol[4];
@@ -261,13 +261,11 @@ void dave_device::sound_stream_update_legacy(sound_stream &stream, stream_sample
output_volumes[6] = ((m_level[3] & m_level_and[6]) | m_level_or[6]) & m_mame_volumes[3];
output_volumes[7] = ((m_level[3] & m_level_and[7]) | m_level_or[7]) & m_mame_volumes[7];
- left_volume = (output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6])>>2;
- right_volume = (output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7])>>2;
+ left_volume = output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6];
+ right_volume = output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7];
- *(buffer1++) = left_volume;
- *(buffer2++) = right_volume;
-
- samples--;
+ buffer1.put(sampindex, stream_buffer::sample_t(left_volume) * sample_scale);
+ buffer2.put(sampindex, stream_buffer::sample_t(right_volume) * sample_scale);
}
}
diff --git a/src/devices/sound/dave.h b/src/devices/sound/dave.h
index 67df3cc1a5a..7d2da120658 100644
--- a/src/devices/sound/dave.h
+++ b/src/devices/sound/dave.h
@@ -47,7 +47,7 @@ protected:
virtual space_config_vector memory_space_config() const 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 program_r(offs_t offset);
void program_w(offs_t offset, uint8_t data);
diff --git a/src/devices/sound/digitalk.cpp b/src/devices/sound/digitalk.cpp
index f498b0b7e39..9ca0e6fa5f0 100644
--- a/src/devices/sound/digitalk.cpp
+++ b/src/devices/sound/digitalk.cpp
@@ -541,32 +541,32 @@ void digitalker_device::digitalker_step()
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void digitalker_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *sout = outputs[0];
+ auto &sout = outputs[0];
int cpos = 0;
- while(cpos != samples) {
+ constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
+ while(cpos != sout.samples()) {
if(m_zero_count == 0 && m_dac_index == 128)
digitalker_step();
if(m_zero_count) {
- int n = samples - cpos;
- int i;
+ int n = sout.samples() - cpos;
if(n > m_zero_count)
n = m_zero_count;
- for(i=0; i != n; i++)
- sout[cpos++] = 0;
+ sout.fill(0, cpos, n);
+ cpos += n;
m_zero_count -= n;
} else if(m_dac_index != 128) {
- while(cpos != samples && m_dac_index != 128) {
- short v = m_dac[m_dac_index];
+ while(cpos != sout.samples() && m_dac_index != 128) {
+ stream_buffer::sample_t v = stream_buffer::sample_t(m_dac[m_dac_index]) * sample_scale;
int pp = m_pitch_pos;
- while(cpos != samples && pp != m_pitch) {
- sout[cpos++] = v;
+ while(cpos != sout.samples() && pp != m_pitch) {
+ sout.put(cpos++, v);
pp++;
}
if(pp == m_pitch) {
@@ -577,8 +577,8 @@ void digitalker_device::sound_stream_update_legacy(sound_stream &stream, stream_
}
} else {
- while(cpos != samples)
- sout[cpos++] = 0;
+ sout.fill(0, cpos);
+ break;
}
}
}
@@ -655,7 +655,7 @@ void digitalker_device::digitalker_register_for_save()
void digitalker_device::device_start()
{
- m_stream = stream_alloc_legacy(0, 1, clock()/4);
+ m_stream = stream_alloc(0, 1, clock()/4);
m_dac_index = 128;
m_data = 0xff;
m_cs = m_cms = m_wr = 1;
diff --git a/src/devices/sound/digitalk.h b/src/devices/sound/digitalk.h
index 89347d3c5fb..18cc32fd3bd 100644
--- a/src/devices/sound/digitalk.h
+++ b/src/devices/sound/digitalk.h
@@ -29,7 +29,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 digitalker_write(uint8_t *adr, uint8_t vol, int8_t dac);
diff --git a/src/devices/sound/disc_cls.h b/src/devices/sound/disc_cls.h
index 07e95ad3b20..cb043557734 100644
--- a/src/devices/sound/disc_cls.h
+++ b/src/devices/sound/disc_cls.h
@@ -118,12 +118,13 @@ public:
/* Add gain to the output and put into the buffers */
/* Clipping will be handled by the main sound system */
double val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1);
- *m_ptr++ = val;
+ m_outview->put(m_outview_sample++, val * (1.0 / 32768.0));
}
virtual int max_output(void) override { return 0; }
- virtual void set_output_ptr(stream_sample_t *ptr) override { m_ptr = ptr; }
+ virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview_sample = 0; }
private:
- stream_sample_t *m_ptr;
+ write_stream_view *m_outview;
+ u32 m_outview_sample;
};
DISCRETE_CLASS(dso_csvlog, 0,
@@ -230,9 +231,10 @@ public:
//protected:
uint32_t m_stream_in_number;
- stream_sample_t *m_ptr; /* current in ptr for stream */
+ read_stream_view const *m_inview; /* current in ptr for stream */
+ uint32_t m_inview_sample;
private:
- 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);
double m_gain; /* node gain */
double m_offset; /* node offset */
diff --git a/src/devices/sound/disc_inp.hxx b/src/devices/sound/disc_inp.hxx
index 72a47909982..1c6c9a6dba5 100644
--- a/src/devices/sound/disc_inp.hxx
+++ b/src/devices/sound/disc_inp.hxx
@@ -242,21 +242,17 @@ void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, uint8_t dat
#define DSS_INPUT_STREAM__GAIN DISCRETE_INPUT(1)
#define DSS_INPUT_STREAM__OFFSET DISCRETE_INPUT(2)
-void discrete_dss_input_stream_node::stream_generate(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void discrete_dss_input_stream_node::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *ptr = outputs[0];
- int samplenum = samples;
-
- while (samplenum-- > 0)
- *(ptr++) = m_data;
+ outputs[0].fill(m_data * (1.0 / 32768.0));
}
DISCRETE_STEP(dss_input_stream)
{
/* the context pointer is set to point to the current input stream data in discrete_stream_update */
- if (EXPECTED(m_ptr))
+ if (EXPECTED(m_inview))
{
- set_output(0, (*m_ptr) * m_gain + m_offset);
- m_ptr++;
+ set_output(0, m_inview->get(m_inview_sample) * 32768.0 * m_gain + m_offset);
+ m_inview_sample++;
}
else
set_output(0, 0);
@@ -264,7 +260,7 @@ DISCRETE_STEP(dss_input_stream)
DISCRETE_RESET(dss_input_stream)
{
- m_ptr = nullptr;
+ m_inview = nullptr;
m_data = 0;
}
@@ -304,7 +300,7 @@ DISCRETE_START(dss_input_stream)
m_stream_in_number = DSS_INPUT_STREAM__STREAM;
m_gain = DSS_INPUT_STREAM__GAIN;
m_offset = DSS_INPUT_STREAM__OFFSET;
- m_ptr = nullptr;
+ m_inview = nullptr;
m_is_buffered = is_buffered();
m_buffer_stream = nullptr;
@@ -318,7 +314,7 @@ void DISCRETE_CLASS_NAME(dss_input_stream)::stream_start(void)
discrete_sound_device *snd_device = downcast<discrete_sound_device *>(m_device);
//assert(DSS_INPUT_STREAM__STREAM < snd_device->m_input_stream_list.count());
- m_buffer_stream = m_device->machine().sound().stream_alloc_legacy(*snd_device, 0, 1, this->sample_rate(), stream_update_legacy_delegate(&discrete_dss_input_stream_node::stream_generate,this));
+ m_buffer_stream = m_device->machine().sound().stream_alloc(*snd_device, 0, 1, this->sample_rate(), stream_update_delegate(&discrete_dss_input_stream_node::stream_generate,this), STREAM_DEFAULT_FLAGS);
snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream);
}
diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp
index b571126d11d..7d6a84a4fc7 100644
--- a/src/devices/sound/discrete.cpp
+++ b/src/devices/sound/discrete.cpp
@@ -988,7 +988,7 @@ void discrete_sound_device::device_start()
fatalerror("init_nodes() - Couldn't find an output node\n");
/* initialize the stream(s) */
- m_stream = stream_alloc_legacy(m_input_stream_list.count(), m_output_list.count(), m_sample_rate);
+ m_stream = stream_alloc(m_input_stream_list.count(), m_output_list.count(), m_sample_rate);
/* Finalize stream_input_nodes */
for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
@@ -1064,13 +1064,10 @@ void discrete_device::process(int samples)
// our sound stream
//-------------------------------------------------
-void discrete_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void discrete_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int outputnum = 0;
- if (samples == 0)
- return;
-
/* Setup any output streams */
for_each(discrete_sound_output_interface **, node, &m_output_list)
{
@@ -1081,11 +1078,12 @@ void discrete_sound_device::sound_stream_update_legacy(sound_stream &stream, str
/* Setup any input streams */
for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
{
- (*node)->m_ptr = (stream_sample_t *) inputs[(*node)->m_stream_in_number];
+ (*node)->m_inview = &inputs[(*node)->m_stream_in_number];
+ (*node)->m_inview_sample = 0;
}
/* just process it */
- process(samples);
+ process(outputs[0].samples());
}
//-------------------------------------------------
diff --git a/src/devices/sound/discrete.h b/src/devices/sound/discrete.h
index 3375e756f3e..65879da211f 100644
--- a/src/devices/sound/discrete.h
+++ b/src/devices/sound/discrete.h
@@ -4248,7 +4248,7 @@ class discrete_sound_output_interface
public:
virtual ~discrete_sound_output_interface() { }
- virtual void set_output_ptr(stream_sample_t *ptr) = 0;
+ virtual void set_output_ptr(write_stream_view &view) = 0;
};
//**************************************************************************
@@ -4387,7 +4387,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;
private:
/* the output stream */