summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2020-09-17 01:24:17 -0700
committer Aaron Giles <aaron@aarongiles.com>2020-09-17 01:24:17 -0700
commit8d7d01caef380b119fbd8653fa5ad23e0d592564 (patch)
tree69ad747e9a42081425070a010fff86688bf67b54
parentdc0ede3c90717ed25de0695c555b861f06344f18 (diff)
Revert "sound: Improved view interfaces to match usage patterns"
This reverts commit dc0ede3c90717ed25de0695c555b861f06344f18.
-rw-r--r--src/devices/cpu/tms57002/tms57002.cpp16
-rw-r--r--src/devices/machine/netlist.cpp8
-rw-r--r--src/devices/machine/netlist.h2
-rw-r--r--src/devices/sound/aica.cpp8
-rw-r--r--src/devices/sound/asc.cpp14
-rw-r--r--src/devices/sound/astrocde.cpp7
-rw-r--r--src/devices/sound/awacs.cpp6
-rw-r--r--src/devices/sound/ay8910.cpp24
-rw-r--r--src/devices/sound/beep.cpp4
-rw-r--r--src/devices/sound/c140.cpp12
-rw-r--r--src/devices/sound/c352.cpp10
-rw-r--r--src/devices/sound/c6280.cpp28
-rw-r--r--src/devices/sound/cdda.cpp17
-rw-r--r--src/devices/sound/cdp1863.cpp4
-rw-r--r--src/devices/sound/cdp1864.cpp4
-rw-r--r--src/devices/sound/cdp1869.cpp4
-rw-r--r--src/devices/sound/cem3394.cpp6
-rw-r--r--src/devices/sound/dac.h40
-rw-r--r--src/devices/sound/dave.cpp6
-rw-r--r--src/devices/sound/digitalk.cpp18
-rw-r--r--src/devices/sound/disc_cls.h6
-rw-r--r--src/devices/sound/disc_inp.hxx5
-rw-r--r--src/devices/sound/discrete.cpp1
-rw-r--r--src/devices/sound/k054539.cpp6
-rw-r--r--src/devices/sound/namco.cpp24
-rw-r--r--src/devices/sound/okim6295.cpp4
-rw-r--r--src/devices/sound/pokey.cpp8
-rw-r--r--src/devices/sound/samples.cpp6
-rw-r--r--src/devices/sound/sn76496.cpp6
-rw-r--r--src/devices/sound/sp0250.cpp14
-rw-r--r--src/devices/sound/tms3615.cpp6
-rw-r--r--src/devices/sound/tms5220.cpp6
-rw-r--r--src/devices/sound/upd7759.cpp8
-rw-r--r--src/devices/sound/vgm_visualizer.cpp4
-rw-r--r--src/devices/sound/votrax.cpp4
-rw-r--r--src/devices/sound/ym2151.cpp6
-rw-r--r--src/devices/video/i8244.cpp4
-rw-r--r--src/emu/disound.cpp6
-rw-r--r--src/emu/sound.cpp41
-rw-r--r--src/emu/sound.h70
-rw-r--r--src/emu/speaker.cpp11
-rw-r--r--src/mame/audio/sente6vb.cpp4
42 files changed, 239 insertions, 249 deletions
diff --git a/src/devices/cpu/tms57002/tms57002.cpp b/src/devices/cpu/tms57002/tms57002.cpp
index dcc6e615cea..c2cf28f3f92 100644
--- a/src/devices/cpu/tms57002/tms57002.cpp
+++ b/src/devices/cpu/tms57002/tms57002.cpp
@@ -924,16 +924,16 @@ void tms57002_device::sound_stream_update(sound_stream &stream, std::vector<read
assert(outputs[0].samples() == 1);
stream_buffer::sample_t in_scale = 32768.0 * ((st0 & ST0_SIM) ? 256.0 : 1.0);
- si[0] = s32(inputs[0].get() * in_scale) & 0xffffff;
- si[1] = s32(inputs[1].get() * in_scale) & 0xffffff;
- si[2] = s32(inputs[2].get() * in_scale) & 0xffffff;
- si[3] = s32(inputs[3].get() * in_scale) & 0xffffff;
+ si[0] = s32(inputs[0].get(0) * in_scale) & 0xffffff;
+ si[1] = s32(inputs[1].get(0) * in_scale) & 0xffffff;
+ si[2] = s32(inputs[2].get(0) * in_scale) & 0xffffff;
+ si[3] = s32(inputs[3].get(0) * in_scale) & 0xffffff;
stream_buffer::sample_t out_scale = 1.0 / (32768.0 * 65536.0);
- outputs[0].put(stream_buffer::sample_t(s32(so[0] << 8)) * out_scale);
- outputs[1].put(stream_buffer::sample_t(s32(so[1] << 8)) * out_scale);
- outputs[2].put(stream_buffer::sample_t(s32(so[2] << 8)) * out_scale);
- outputs[3].put(stream_buffer::sample_t(s32(so[3] << 8)) * out_scale);
+ outputs[0].put(0, stream_buffer::sample_t(s32(so[0] << 8)) * out_scale);
+ outputs[1].put(0, stream_buffer::sample_t(s32(so[1] << 8)) * out_scale);
+ outputs[2].put(0, stream_buffer::sample_t(s32(so[2] << 8)) * out_scale);
+ outputs[3].put(0, stream_buffer::sample_t(s32(so[3] << 8)) * out_scale);
sync_w(1);
}
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp
index 06e574890d2..988c21c33e1 100644
--- a/src/devices/machine/netlist.cpp
+++ b/src/devices/machine/netlist.cpp
@@ -825,10 +825,10 @@ void netlist_mame_stream_output_device::sound_update_fill(write_stream_view &tar
if (target.samples() < m_buffer.size())
osd_printf_warning("sound %s: samples %d less bufsize %d\n", name(), target.samples(), m_buffer.size());
- int sampindex = 0;
- while (!target.done() && sampindex < m_buffer.size())
- target.put(m_buffer[sampindex++]);
- target.fill(m_cur);
+ int sampindex;
+ for (sampindex = 0; sampindex < m_buffer.size(); sampindex++)
+ target.put(sampindex, m_buffer[sampindex]);
+ target.fill(m_cur, sampindex);
}
diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h
index 269f98e415c..8b9e156adba 100644
--- a/src/devices/machine/netlist.h
+++ b/src/devices/machine/netlist.h
@@ -241,7 +241,7 @@ public:
netlist_mame_sound_input_buffer(read_stream_view const &src) :
read_stream_view(src) { }
- stream_buffer::sample_t operator[](std::size_t index) { return get_indexed(index); }
+ stream_buffer::sample_t operator[](std::size_t index) { return get(index); }
};
// ----------------------------------------------------------------------------------------
diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp
index a55199cc3fc..7bedf5d660a 100644
--- a/src/devices/sound/aica.cpp
+++ b/src/devices/sound/aica.cpp
@@ -1234,7 +1234,7 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w
int i;
constexpr stream_buffer::sample_t sample_scale = 1.0 / stream_buffer::sample_t(32768 << SHIFT);
- while (!bufl.done())
+ for (int s = 0; s < bufl.samples(); ++s)
{
s32 smpl = 0, smpr = 0;
@@ -1275,7 +1275,7 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w
{
if (EFSDL(i + 16)) // 16,17 for EXTS
{
- m_DSP.EXTS[i] = s16(inputs[i].get() * 32767.0);
+ m_DSP.EXTS[i] = s16(inputs[i].get(s) * 32767.0);
u32 Enc = ((EFPAN(i + 16)) << 0x8) | ((EFSDL(i + 16)) << 0xd);
smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT;
smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT;
@@ -1293,8 +1293,8 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w
smpr = clip16(smpr >> 3);
}
- bufl.put(stream_buffer::sample_t(smpl * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
- bufr.put(stream_buffer::sample_t(smpr * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
+ bufl.put(s, stream_buffer::sample_t(smpl * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
+ bufr.put(s, stream_buffer::sample_t(smpr * m_LPANTABLE[MVOL() << 0xd]) * sample_scale);
}
}
diff --git a/src/devices/sound/asc.cpp b/src/devices/sound/asc.cpp
index c7e467b617c..e03494040ab 100644
--- a/src/devices/sound/asc.cpp
+++ b/src/devices/sound/asc.cpp
@@ -119,7 +119,7 @@ void asc_device::device_timer(emu_timer &timer, device_timer_id tid, int param,
void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int ch;
+ int i, ch;
static uint32_t wtoffs[2] = { 0, 0x200 };
auto &outL = outputs[0];
@@ -149,7 +149,7 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre
case 1: // FIFO mode
{
constexpr stream_buffer::sample_t sample_scale = 64.0 / 32768.0;
- while (!outL.done())
+ for (i = 0; i < outL.samples(); i++)
{
int8_t smpll, smplr;
@@ -234,8 +234,8 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre
break;
}
- outL.put(stream_buffer::sample_t(smpll) * sample_scale);
- outR.put(stream_buffer::sample_t(smplr) * sample_scale);
+ outL.put(i, stream_buffer::sample_t(smpll) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(smplr) * sample_scale);
}
break;
}
@@ -243,7 +243,7 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre
case 2: // wavetable mode
{
constexpr stream_buffer::sample_t sample_scale = 1.0 / (32768.0 * 4.0);
- while (!outL.done())
+ for (i = 0; i < outL.samples(); i++)
{
int32_t mixL, mixR;
int8_t smpl;
@@ -269,8 +269,8 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre
mixR += smpl*256;
}
- outL.put(stream_buffer::sample_t(mixL) * sample_scale);
- outR.put(stream_buffer::sample_t(mixR) * sample_scale);
+ outL.put(i, stream_buffer::sample_t(mixL) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(mixR) * sample_scale);
}
break;
}
diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp
index fe39bd4ac32..17df6999989 100644
--- a/src/devices/sound/astrocde.cpp
+++ b/src/devices/sound/astrocde.cpp
@@ -144,13 +144,14 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<
/* loop over samples */
int samples_this_time;
constexpr stream_buffer::sample_t sample_scale = 1.0f / 60.0f;
- while (!dest.done())
+ for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time)
{
stream_sample_t cursample = 0;
/* compute the number of cycles until the next master oscillator reset */
/* or until the next noise boundary */
- samples_this_time = std::min(256 - master_count, 64 - noise_clock);
+ samples_this_time = std::min<int>(dest.samples() - sampindex, 256 - master_count);
+ samples_this_time = std::min(samples_this_time, 64 - noise_clock);
/* sum the output of the tone generators */
if (m_a_state)
@@ -165,7 +166,7 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<
cursample += m_reg[7] >> 4;
/* scale to max and output */
- samples_this_time = dest.fill(stream_buffer::sample_t(cursample) * sample_scale, samples_this_time);
+ dest.fill(stream_buffer::sample_t(cursample) * sample_scale, sampindex, samples_this_time);
/* clock the noise; a 2-bit counter clocks a 4-bit counter which clocks the LFSR */
noise_clock += samples_this_time;
diff --git a/src/devices/sound/awacs.cpp b/src/devices/sound/awacs.cpp
index 007217db048..19f734cd468 100644
--- a/src/devices/sound/awacs.cpp
+++ b/src/devices/sound/awacs.cpp
@@ -96,10 +96,10 @@ void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_st
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
if (m_playback_enable)
{
- while (!outL.done())
+ for (int i = 0; i < outL.samples(); i++)
{
- outL.put(stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr))) * sample_scale);
- outR.put(stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr + 2))) * sample_scale);
+ outL.put(i, stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr))) * sample_scale);
+ outR.put(i, stream_buffer::sample_t(s16(m_dma_space->read_word(offset + m_play_ptr + 2))) * sample_scale);
m_play_ptr += 4;
}
diff --git a/src/devices/sound/ay8910.cpp b/src/devices/sound/ay8910.cpp
index 0152d83620a..26e99cf1bc7 100644
--- a/src/devices/sound/ay8910.cpp
+++ b/src/devices/sound/ay8910.cpp
@@ -1086,10 +1086,12 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s
tone_t *tone;
envelope_t *envelope;
+ int samples = outputs[0].samples();
+
/* hack to prevent us from hanging when starting filtered outputs */
if (!m_ready)
{
- for (int chan = 0; chan < outputs.size(); chan++)
+ for (int chan = 0; chan < m_streams; chan++)
outputs[chan].fill(0);
}
@@ -1101,7 +1103,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s
/* is 1, not 0, and can be modulated changing the volume. */
/* buffering loop */
- while (!outputs[0].done())
+ for (int sampindex = 0; sampindex < samples; sampindex++)
{
for (int chan = 0; chan < NUM_CHANNELS; chan++)
{
@@ -1197,38 +1199,38 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s
{
env_volume >>= 1;
if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field
- outputs[chan].put(m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
+ outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
else
- outputs[chan].put(m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
+ outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
}
else
{
if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field
- outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
+ outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
else
- outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
+ outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
}
}
else
{
if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field
- outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
+ outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
else
- outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
+ outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
}
}
else
{
if (is_expanded_mode())
- outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
+ outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
else
- outputs[chan].put(m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
+ outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
}
}
}
else
{
- outputs[0].put(mix_3D());
+ outputs[0].put(sampindex, mix_3D());
}
}
}
diff --git a/src/devices/sound/beep.cpp b/src/devices/sound/beep.cpp
index a9cfd6747cc..58096c4b561 100644
--- a/src/devices/sound/beep.cpp
+++ b/src/devices/sound/beep.cpp
@@ -83,9 +83,9 @@ void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_str
}
/* fill in the sample */
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- buffer.put(signal);
+ buffer.put(sampindex, signal);
incr -= clock;
while( incr < 0 )
{
diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp
index 0227fd47d08..0edb1920a8c 100644
--- a/src/devices/sound/c140.cpp
+++ b/src/devices/sound/c140.cpp
@@ -327,14 +327,14 @@ void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_str
auto &dest1 = outputs[0];
auto &dest2 = outputs[1];
constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0;
- while (!dest1.done())
+ for (int i = 0; i < samples; i++)
{
stream_buffer::sample_t val;
val = stream_buffer::sample_t(*lmix++) * sample_scale;
- dest1.put(limit(val));
+ dest1.put(i, limit(val));
val = stream_buffer::sample_t(*rmix++) * sample_scale;
- dest2.put(limit(val));
+ dest2.put(i, limit(val));
}
}
}
@@ -466,14 +466,14 @@ void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_str
auto &dest1 = outputs[0];
auto &dest2 = outputs[1];
constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0;
- while (!dest1.done())
+ for (int i = 0; i < samples; i++)
{
stream_buffer::sample_t val;
val = stream_buffer::sample_t(*lmix++) * sample_scale;
- dest1.put(limit(val));
+ dest1.put(i, limit(val));
val = stream_buffer::sample_t(*rmix++) * sample_scale;
- dest2.put(limit(val));
+ dest2.put(i, limit(val));
}
}
}
diff --git a/src/devices/sound/c352.cpp b/src/devices/sound/c352.cpp
index f2b7dd27506..826f194437a 100644
--- a/src/devices/sound/c352.cpp
+++ b/src/devices/sound/c352.cpp
@@ -130,7 +130,7 @@ void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_str
auto &buffer_rr = outputs[3];
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!buffer_fl.done())
+ for (int i = 0; i < buffer_fl.samples(); i++)
{
int out[4] = { 0, 0, 0, 0 };
@@ -174,10 +174,10 @@ void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_str
out[3] += (((v.flags & C352_FLG_PHASEFR) ? -s : s) * v.curr_vol[3]) >> 8;
}
- buffer_fl.put(stream_buffer::sample_t(s16(out[0] >> 3)) * sample_scale);
- buffer_fr.put(stream_buffer::sample_t(s16(out[1] >> 3)) * sample_scale);
- buffer_rl.put(stream_buffer::sample_t(s16(out[2] >> 3)) * sample_scale);
- buffer_rr.put(stream_buffer::sample_t(s16(out[3] >> 3)) * sample_scale);
+ buffer_fl.put(i, stream_buffer::sample_t(s16(out[0] >> 3)) * sample_scale);
+ buffer_fr.put(i, stream_buffer::sample_t(s16(out[1] >> 3)) * sample_scale);
+ buffer_rl.put(i, stream_buffer::sample_t(s16(out[2] >> 3)) * sample_scale);
+ buffer_rr.put(i, stream_buffer::sample_t(s16(out[3] >> 3)) * sample_scale);
}
}
diff --git a/src/devices/sound/c6280.cpp b/src/devices/sound/c6280.cpp
index e8de8151be6..d01dd74125a 100644
--- a/src/devices/sound/c6280.cpp
+++ b/src/devices/sound/c6280.cpp
@@ -55,10 +55,6 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
for (int ch = 0; ch < 6; ch++)
{
channel *chan = &m_channel[ch];
-
- outputs[0].reset();
- outputs[1].reset();
-
/* Only look at enabled channels */
if (chan->control & 0x80)
{
@@ -81,7 +77,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
{
/* Noise mode */
const u32 step = (chan->noise_control & 0x1f) ^ 0x1f;
- while (!outputs[0].done())
+ for (int i = 0; i < outputs[0].samples(); i += 1)
{
s16 data = BIT(chan->noise_seed, 0) ? 0x1f : 0;
chan->noise_counter--;
@@ -92,18 +88,18 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
// based on Charles MacDonald's research
chan->noise_seed = (seed >> 1) | ((BIT(seed, 0) ^ BIT(seed, 1) ^ BIT(seed, 11) ^ BIT(seed, 12) ^ BIT(seed, 17)) << 17);
}
- outputs[0].add(stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
- outputs[1].add(stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
+ outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
+ outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
}
}
else
if (chan->control & 0x40)
{
/* DDA mode */
- while (!outputs[0].done())
+ for (int i = 0; i < outputs[0].samples(); i++)
{
- outputs[0].add(stream_buffer::sample_t(s16(vll * (chan->dda - 16))) * sample_scale);
- outputs[1].add(stream_buffer::sample_t(s16(vlr * (chan->dda - 16))) * sample_scale);
+ outputs[0].add(i, stream_buffer::sample_t(s16(vll * (chan->dda - 16))) * sample_scale);
+ outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (chan->dda - 16))) * sample_scale);
}
}
else
@@ -116,7 +112,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
channel *lfo_srcchan = &m_channel[1];
channel *lfo_dstchan = &m_channel[0];
const u16 lfo_step = lfo_srcchan->frequency ? lfo_srcchan->frequency : 0x1000;
- while (!outputs[0].done())
+ for (int i = 0; i < outputs[0].samples(); i += 1)
{
s32 step = lfo_dstchan->frequency ? lfo_dstchan->frequency : 0x1000;
if (m_lfo_control & 0x80) // reset LFO
@@ -142,8 +138,8 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
lfo_dstchan->tick = step;
lfo_dstchan->index = (lfo_dstchan->index + 1) & 0x1f;
}
- outputs[0].add(stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
- outputs[1].add(stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
+ outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
+ outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
}
}
}
@@ -151,7 +147,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
{
/* Waveform mode */
const u32 step = chan->frequency ? chan->frequency : 0x1000;
- while (!outputs[0].done())
+ for (int i = 0; i < outputs[0].samples(); i += 1)
{
const s16 data = chan->waveform[chan->index];
chan->tick--;
@@ -160,8 +156,8 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
chan->tick = step;
chan->index = (chan->index + 1) & 0x1f;
}
- outputs[0].add(stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
- outputs[1].add(stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
+ outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale);
+ outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale);
}
}
}
diff --git a/src/devices/sound/cdda.cpp b/src/devices/sound/cdda.cpp
index 4cecdc95ee7..ca2bd280de8 100644
--- a/src/devices/sound/cdda.cpp
+++ b/src/devices/sound/cdda.cpp
@@ -18,8 +18,8 @@
void cdda_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
get_audio_data(outputs[0], outputs[1]);
- m_audio_volume[0] = outputs[0].get_indexed(0);
- m_audio_volume[1] = outputs[1].get_indexed(0);
+ m_audio_volume[0] = outputs[0].get(0);
+ m_audio_volume[1] = outputs[1].get(0);
}
//-------------------------------------------------
@@ -165,7 +165,7 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf
int16_t *audio_cache = (int16_t *) m_audio_cache.get();
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!bufL.done())
+ for (int sampindex = 0; sampindex < bufL.samples(); )
{
/* if no file, audio not playing, audio paused, or out of disc data,
just zero fill */
@@ -177,12 +177,12 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf
m_audio_ended_normally = true;
}
- bufL.fill(0);
- bufR.fill(0);
+ bufL.fill(0, sampindex);
+ bufR.fill(0, sampindex);
return;
}
- int samples = bufL.remaining();
+ int samples = bufL.samples() - sampindex;
if (samples > m_audio_samples)
{
samples = m_audio_samples;
@@ -191,10 +191,11 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf
for (i = 0; i < samples; i++)
{
/* CD-DA data on the disc is big-endian */
- bufL.put(stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++;
- bufR.put(stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++;
+ bufL.put(sampindex + i, stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++;
+ bufR.put(sampindex + i, stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++;
}
+ sampindex += samples;
m_audio_samples -= samples;
if (m_audio_samples == 0)
diff --git a/src/devices/sound/cdp1863.cpp b/src/devices/sound/cdp1863.cpp
index fd84ff0cd75..984a306b28a 100644
--- a/src/devices/sound/cdp1863.cpp
+++ b/src/devices/sound/cdp1863.cpp
@@ -114,9 +114,9 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_
signal = 1.0;
}
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- buffer.put(signal);
+ buffer.put(sampindex, signal);
incr -= frequency;
while( incr < 0 )
{
diff --git a/src/devices/sound/cdp1864.cpp b/src/devices/sound/cdp1864.cpp
index 87901a6dd1b..e8168004811 100644
--- a/src/devices/sound/cdp1864.cpp
+++ b/src/devices/sound/cdp1864.cpp
@@ -279,9 +279,9 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_
signal = 1.0;
}
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- buffer.put(signal);
+ buffer.put(sampindex, signal);
incr -= frequency;
while( incr < 0 )
{
diff --git a/src/devices/sound/cdp1869.cpp b/src/devices/sound/cdp1869.cpp
index d4b789f3297..98580d7ae54 100644
--- a/src/devices/sound/cdp1869.cpp
+++ b/src/devices/sound/cdp1869.cpp
@@ -534,9 +534,9 @@ void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_
signal = stream_buffer::sample_t(m_toneamp) / 15.0;
}
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- buffer.put(signal);
+ buffer.put(sampindex, signal);
incr -= frequency;
while( incr < 0 )
{
diff --git a/src/devices/sound/cem3394.cpp b/src/devices/sound/cem3394.cpp
index e6966e49a3d..5b288d2d700 100644
--- a/src/devices/sound/cem3394.cpp
+++ b/src/devices/sound/cem3394.cpp
@@ -219,7 +219,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_
logerror("%f V didn't cut it\n", m_values[WAVE_SELECT]);
// loop over samples
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
// get the current VCO position and step it forward
double vco_position = m_vco_position;
@@ -250,7 +250,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_
// compute extension input (for Bally/Sente this is the noise)
if (ENABLE_EXTERNAL)
- result += EXTERNAL_VOLUME * m_mixer_external * external.get();
+ result += EXTERNAL_VOLUME * m_mixer_external * external.get(sampindex);
// compute the modulated filter frequency and apply the filter
// modulation tracks the VCO triangle
@@ -258,7 +258,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_
result = filter(result, filter_freq);
// write the sample
- buffer.put(result * m_volume);
+ buffer.put(sampindex, result * m_volume);
}
}
diff --git a/src/devices/sound/dac.h b/src/devices/sound/dac.h
index b45dc66dfad..7a48ba80998 100644
--- a/src/devices/sound/dac.h
+++ b/src/devices/sound/dac.h
@@ -87,12 +87,12 @@ protected:
virtual void sound_stream_update_tag(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
- double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
+ double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
+ double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = vref_neg + dac_multiply<bits>(vref_pos - vref_neg, this->m_code);
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
};
@@ -107,20 +107,20 @@ protected:
{
if (this->m_code & (1 << (bits - 1)))
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
+ double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_neg, this->m_code ^ ~(~0U << bits));
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
else
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
+ double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_pos, this->m_code);
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
}
@@ -134,12 +134,12 @@ protected:
virtual void sound_stream_update_tag(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
- double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
+ double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
+ double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = vref_neg + dac_multiply<bits>(vref_pos - vref_neg, this->m_code ^ (1 << (bits - 1)));
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
};
@@ -154,20 +154,20 @@ protected:
{
if (this->m_code & (1 << (bits - 1)))
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
+ double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_neg, this->m_code ^ (1 << (bits - 1)));
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
else
{
- while (!outputs[0].done())
+ for (int samp = 0; samp < outputs[0].samples(); samp++)
{
- double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
+ double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_pos, this->m_code);
- outputs[0].put(vout);
+ outputs[0].put(samp, vout);
}
}
}
diff --git a/src/devices/sound/dave.cpp b/src/devices/sound/dave.cpp
index 1c82ab6691e..f26ea891879 100644
--- a/src/devices/sound/dave.cpp
+++ b/src/devices/sound/dave.cpp
@@ -206,7 +206,7 @@ void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_str
auto &buffer2 = outputs[1];
constexpr stream_buffer::sample_t sample_scale = 1.0 / (4.0 * 32768.0);
- while (!buffer1.done())
+ for (int sampindex = 0; sampindex < buffer1.samples(); sampindex++)
{
int vol[4];
@@ -264,8 +264,8 @@ void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_str
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.put(stream_buffer::sample_t(left_volume) * sample_scale);
- buffer2.put(stream_buffer::sample_t(right_volume) * sample_scale);
+ 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/digitalk.cpp b/src/devices/sound/digitalk.cpp
index 6fe7cfe75b0..9ca0e6fa5f0 100644
--- a/src/devices/sound/digitalk.cpp
+++ b/src/devices/sound/digitalk.cpp
@@ -547,20 +547,26 @@ void digitalker_device::digitalker_step()
void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
auto &sout = outputs[0];
+ int cpos = 0;
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!sout.done()) {
+ while(cpos != sout.samples()) {
if(m_zero_count == 0 && m_dac_index == 128)
digitalker_step();
if(m_zero_count) {
- m_zero_count -= sout.fill(0, m_zero_count);
+ int n = sout.samples() - cpos;
+ if(n > m_zero_count)
+ n = m_zero_count;
+ sout.fill(0, cpos, n);
+ cpos += n;
+ m_zero_count -= n;
} else if(m_dac_index != 128) {
- while(!sout.done() && m_dac_index != 128) {
+ 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(!sout.done() && pp != m_pitch) {
- sout.put(v);
+ while(cpos != sout.samples() && pp != m_pitch) {
+ sout.put(cpos++, v);
pp++;
}
if(pp == m_pitch) {
@@ -571,7 +577,7 @@ void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<re
}
} else {
- sout.fill(0);
+ sout.fill(0, cpos);
break;
}
}
diff --git a/src/devices/sound/disc_cls.h b/src/devices/sound/disc_cls.h
index 3162d956f22..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_outview->put(val * (1.0 / 32768.0));
+ m_outview->put(m_outview_sample++, val * (1.0 / 32768.0));
}
virtual int max_output(void) override { return 0; }
- virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview->reset(); }
+ virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview_sample = 0; }
private:
write_stream_view *m_outview;
+ u32 m_outview_sample;
};
DISCRETE_CLASS(dso_csvlog, 0,
@@ -231,6 +232,7 @@ public:
//protected:
uint32_t m_stream_in_number;
read_stream_view const *m_inview; /* current in ptr for stream */
+ uint32_t m_inview_sample;
private:
void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
diff --git a/src/devices/sound/disc_inp.hxx b/src/devices/sound/disc_inp.hxx
index 729227dea24..1c6c9a6dba5 100644
--- a/src/devices/sound/disc_inp.hxx
+++ b/src/devices/sound/disc_inp.hxx
@@ -250,7 +250,10 @@ 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_inview))
- set_output(0, m_inview->get() * 32768.0 * m_gain + m_offset);
+ {
+ set_output(0, m_inview->get(m_inview_sample) * 32768.0 * m_gain + m_offset);
+ m_inview_sample++;
+ }
else
set_output(0, 0);
}
diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp
index 9e3b4f60d0c..7d6a84a4fc7 100644
--- a/src/devices/sound/discrete.cpp
+++ b/src/devices/sound/discrete.cpp
@@ -1079,6 +1079,7 @@ void discrete_sound_device::sound_stream_update(sound_stream &stream, std::vecto
for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
{
(*node)->m_inview = &inputs[(*node)->m_stream_in_number];
+ (*node)->m_inview_sample = 0;
}
/* just process it */
diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp
index 4a271009fa1..2ed7dc134a2 100644
--- a/src/devices/sound/k054539.cpp
+++ b/src/devices/sound/k054539.cpp
@@ -125,7 +125,7 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_
}
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!outputs[0].done()) {
+ for(int sample = 0; sample != outputs[0].samples(); sample++) {
double lval, rval;
if(!(flags & DISABLE_REVERB))
lval = rval = rbase[reverb_pos];
@@ -303,8 +303,8 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_
}
}
reverb_pos = (reverb_pos + 1) & 0x1fff;
- outputs[0].put(stream_buffer::sample_t(lval) * sample_scale);
- outputs[1].put(stream_buffer::sample_t(rval) * sample_scale);
+ outputs[0].put(sample, stream_buffer::sample_t(lval) * sample_scale);
+ outputs[1].put(sample, stream_buffer::sample_t(rval) * sample_scale);
}
}
diff --git a/src/devices/sound/namco.cpp b/src/devices/sound/namco.cpp
index cdad9636209..830f3713b45 100644
--- a/src/devices/sound/namco.cpp
+++ b/src/devices/sound/namco.cpp
@@ -237,9 +237,9 @@ void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase)
/* generate sound by oversampling */
uint32_t namco_audio_device::namco_update_one(write_stream_view &buffer, const int16_t *wave, uint32_t counter, uint32_t freq)
{
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
- buffer.add(stream_buffer::sample_t(wave[WAVEFORM_POSITION(counter)]) * sample_scale);
+ buffer.add(sampindex, stream_buffer::sample_t(wave[WAVEFORM_POSITION(counter)]) * sample_scale);
counter += freq;
}
@@ -672,8 +672,8 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r
/* loop over each voice and add its contribution */
for (sound_channel *voice = m_channel_list; voice < m_last_channel; voice++)
{
- auto &lmix = outputs[0].reset();
- auto &rmix = outputs[1].reset();
+ auto &lmix = outputs[0];
+ auto &rmix = outputs[1];
int lv = voice->volume[0];
int rv = voice->volume[1];
@@ -699,13 +699,13 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r
if (voice->noise_state)
{
- lmix.add(stream_buffer::sample_t(l_noise_data) * sample_scale);
- rmix.add(stream_buffer::sample_t(r_noise_data) * sample_scale);
+ lmix.add(i, stream_buffer::sample_t(l_noise_data) * sample_scale);
+ rmix.add(i, stream_buffer::sample_t(r_noise_data) * sample_scale);
}
else
{
- lmix.add(stream_buffer::sample_t(-l_noise_data) * sample_scale);
- rmix.add(stream_buffer::sample_t(-r_noise_data) * sample_scale);
+ lmix.add(i, stream_buffer::sample_t(-l_noise_data) * sample_scale);
+ rmix.add(i, stream_buffer::sample_t(-r_noise_data) * sample_scale);
}
if (hold)
@@ -779,7 +779,6 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r
/* loop over each voice and add its contribution */
for (voice = m_channel_list; voice < m_last_channel; voice++)
{
- buffer.reset();
int v = voice->volume[0];
if (voice->noise_sw)
{
@@ -792,16 +791,17 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r
uint32_t delta = f << 4;
uint32_t c = voice->noise_counter;
int16_t noise_data = OUTPUT_LEVEL(0x07 * (v >> 1));
+ int i;
/* add our contribution */
- while (!buffer.done())
+ for (i = 0; i < buffer.samples(); i++)
{
int cnt;
if (voice->noise_state)
- buffer.add(stream_buffer::sample_t(noise_data) * sample_scale);
+ buffer.add(i, stream_buffer::sample_t(noise_data) * sample_scale);
else
- buffer.add(stream_buffer::sample_t(-noise_data) * sample_scale);
+ buffer.add(i, stream_buffer::sample_t(-noise_data) * sample_scale);
if (hold)
{
diff --git a/src/devices/sound/okim6295.cpp b/src/devices/sound/okim6295.cpp
index 29461f7f37c..c3aee26e52e 100644
--- a/src/devices/sound/okim6295.cpp
+++ b/src/devices/sound/okim6295.cpp
@@ -182,7 +182,7 @@ void okim6295_device::sound_stream_update(sound_stream &stream, std::vector<read
// iterate over voices and accumulate sample data
for (auto & elem : m_voice)
- elem.generate_adpcm(*this, outputs[0].reset());
+ elem.generate_adpcm(*this, outputs[0]);
}
@@ -352,7 +352,7 @@ void okim6295_device::okim_voice::generate_adpcm(device_rom_interface &rom, writ
// output to the buffer, scaling by the volume
// signal in range -2048..2047
- buffer.add(m_adpcm.clock(nibble) * sample_scale * m_volume);
+ buffer.add(sampindex, m_adpcm.clock(nibble) * sample_scale * m_volume);
// next!
if (++m_sample >= m_count)
diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp
index f405cd01255..f749afad2ae 100644
--- a/src/devices/sound/pokey.cpp
+++ b/src/devices/sound/pokey.cpp
@@ -702,11 +702,11 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st
double V0 = rTot / (rTot+m_r_pullup) * m_v_ref / 5.0;
double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-(rTot + m_r_pullup) / (m_cap * m_r_pullup * rTot) * m_clock_period.as_double());
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
/* store sum of output signals into the buffer */
m_out_filter += (V0 - m_out_filter) * mult;
- buffer.put(m_out_filter);
+ buffer.put(sampindex, m_out_filter);
}
}
else if (m_output_type == OPAMP_C_TO_GROUND)
@@ -734,11 +734,11 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st
double V0 = (m_r_pullup / rTot) * m_v_ref / 5.0;
double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-1.0 / (m_cap * m_r_pullup) * m_clock_period.as_double());
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
/* store sum of output signals into the buffer */
m_out_filter += (V0 - m_out_filter) * mult;
- buffer.put(m_out_filter);
+ buffer.put(sampindex, m_out_filter);
}
}
else if (m_output_type == DISCRETE_VAR_R)
diff --git a/src/devices/sound/samples.cpp b/src/devices/sound/samples.cpp
index bfe7c02bb6b..5c8d129b799 100644
--- a/src/devices/sound/samples.cpp
+++ b/src/devices/sound/samples.cpp
@@ -334,7 +334,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_
double endpos = chan.source_len;
const int16_t *sample = chan.source;
- while (!buffer.done())
+ for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
{
// do a linear interp on the sample
double pos_floor = floor(chan.pos);
@@ -343,7 +343,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_
stream_buffer::sample_t sample1 = stream_buffer::sample_t(sample[ipos++]);
stream_buffer::sample_t sample2 = stream_buffer::sample_t(sample[(ipos + 1) % chan.source_len]);
- buffer.put(sample_scale * ((1.0 - frac) * sample1 + frac * sample2));
+ buffer.put(sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2));
// advance
chan.pos += step;
@@ -357,7 +357,7 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_
{
chan.source = nullptr;
chan.source_num = -1;
- buffer.fill(0);
+ buffer.fill(0, sampindex);
break;
}
}
diff --git a/src/devices/sound/sn76496.cpp b/src/devices/sound/sn76496.cpp
index 6dcfe18c939..9bc686dedb2 100644
--- a/src/devices/sound/sn76496.cpp
+++ b/src/devices/sound/sn76496.cpp
@@ -379,7 +379,7 @@ void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector<
int16_t out2 = 0;
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!lbuffer->done())
+ for (int sampindex = 0; sampindex < lbuffer->samples(); sampindex++)
{
// clock chip once
if (m_current_clock > 0) // not ready for new divided clock
@@ -445,9 +445,9 @@ void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector<
if (m_negate) { out = -out; out2 = -out2; }
- lbuffer->put(stream_buffer::sample_t(out) * sample_scale);
+ lbuffer->put(sampindex, stream_buffer::sample_t(out) * sample_scale);
if (m_stereo)
- rbuffer->put(stream_buffer::sample_t(out2) * sample_scale);
+ rbuffer->put(sampindex, stream_buffer::sample_t(out2) * sample_scale);
}
}
diff --git a/src/devices/sound/sp0250.cpp b/src/devices/sound/sp0250.cpp
index da836cde53c..e18143a29b0 100644
--- a/src/devices/sound/sp0250.cpp
+++ b/src/devices/sound/sp0250.cpp
@@ -259,12 +259,12 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s
if (!m_pwm_mode)
{
constexpr stream_buffer::sample_t sample_scale = 1.0 / 128.0;
- while (!output.done())
- output.put(stream_buffer::sample_t(next()) * sample_scale);
+ for (int sampindex = 0; sampindex < output.samples(); sampindex++)
+ output.put(sampindex, stream_buffer::sample_t(next()) * sample_scale);
}
else
{
- while (!output.done())
+ for (int sampindex = 0; sampindex < output.samples(); )
{
// see where we're at in the current PWM cycle
if (m_pwm_index >= PWM_CLOCKS)
@@ -291,8 +291,14 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s
remaining = PWM_CLOCKS - m_pwm_index;
}
+ // clamp to the number of samples requested and advance the counters
+ if (remaining > output.samples() - sampindex)
+ remaining = output.samples() - sampindex;
+ m_pwm_index += remaining;
+
// fill the output
- m_pwm_index += outputs[0].fill(value, remaining);
+ while (remaining-- != 0)
+ outputs[0].put(sampindex++, value);
}
}
}
diff --git a/src/devices/sound/tms3615.cpp b/src/devices/sound/tms3615.cpp
index 53c1df7d52a..e59c64eab04 100644
--- a/src/devices/sound/tms3615.cpp
+++ b/src/devices/sound/tms3615.cpp
@@ -57,7 +57,7 @@ void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_
int samplerate = buffer8.sample_rate();
constexpr stream_buffer::sample_t VMAX = 1.0f / stream_buffer::sample_t(TMS3615_TONES);
- while (!buffer8.done())
+ for (int sampindex = 0; sampindex < buffer8.samples(); sampindex++)
{
stream_buffer::sample_t sum8 = 0, sum16 = 0;
@@ -94,8 +94,8 @@ void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_
}
}
- buffer8.put(sum8);
- buffer16.put(sum16);
+ buffer8.put(sampindex, sum8);
+ buffer16.put(sampindex, sum16);
}
}
diff --git a/src/devices/sound/tms5220.cpp b/src/devices/sound/tms5220.cpp
index 227de0f2be9..9c4974c34e2 100644
--- a/src/devices/sound/tms5220.cpp
+++ b/src/devices/sound/tms5220.cpp
@@ -2062,14 +2062,14 @@ void tms5220_device::sound_stream_update(sound_stream &stream, std::vector<read_
/* loop while we still have samples to generate */
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!output.done())
+ for (int sampindex = 0; sampindex < output.samples(); )
{
- int length = (output.remaining() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.remaining();
+ int length = (output.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.samples();
/* generate the samples and copy to the target buffer */
process(sample_data, length);
for (int index = 0; index < length; index++)
- output.put(sample_data[index] * sample_scale);
+ output.put(sampindex++, sample_data[index] * sample_scale);
}
}
diff --git a/src/devices/sound/upd7759.cpp b/src/devices/sound/upd7759.cpp
index 1da8fd7c11c..fc07c0f95ab 100644
--- a/src/devices/sound/upd7759.cpp
+++ b/src/devices/sound/upd7759.cpp
@@ -738,11 +738,12 @@ void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_
uint32_t pos = m_pos;
/* loop until done */
+ u32 index = 0;
if (m_state != STATE_IDLE)
- while (!outputs[0].done())
+ for ( ; index < outputs[0].samples(); index++)
{
/* store the current sample */
- outputs[0].put(sample);
+ outputs[0].put(index, sample);
/* advance by the number of clocks/output sample */
pos += step;
@@ -774,7 +775,8 @@ void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_
}
/* if we got out early, just zap the rest of the buffer */
- outputs[0].fill(0);
+ for (; index < outputs[0].samples(); index++)
+ outputs[0].put(index, 0);
/* flush the state back */
m_clocks_left = clocks_left;
diff --git a/src/devices/sound/vgm_visualizer.cpp b/src/devices/sound/vgm_visualizer.cpp
index 46471760328..c1f438f2b2c 100644
--- a/src/devices/sound/vgm_visualizer.cpp
+++ b/src/devices/sound/vgm_visualizer.cpp
@@ -289,12 +289,12 @@ void vgmviz_device::sound_stream_update(sound_stream &stream, std::vector<read_s
device_mixer_interface::sound_stream_update(stream, inputs, outputs);
// now consume the outputs
- while (!outputs[0].done())
+ for (int pos = 0; pos < outputs[0].samples(); pos++)
{
for (int i = 0; i < outputs.size(); i++)
{
// Original code took 16-bit sample / 65536.0 instead of 32768.0, so multiply by 0.5 here but is it necessary?
- const float sample = outputs[i].get() * 0.5f;
+ const float sample = outputs[i].get(pos) * 0.5f;
m_audio_buf[m_audio_fill_index][i][m_audio_count[m_audio_fill_index]] = sample + 0.5f;
}
diff --git a/src/devices/sound/votrax.cpp b/src/devices/sound/votrax.cpp
index d8f98bb65cb..000a568d2a3 100644
--- a/src/devices/sound/votrax.cpp
+++ b/src/devices/sound/votrax.cpp
@@ -133,11 +133,11 @@ void votrax_sc01_device::inflection_w(uint8_t data)
void votrax_sc01_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- while (!outputs[0].done()) {
+ for(int i=0; i<outputs[0].samples(); i++) {
m_sample_count++;
if(m_sample_count & 1)
chip_update();
- outputs[0].put(analog_calc());
+ outputs[0].put(i, analog_calc());
}
}
diff --git a/src/devices/sound/ym2151.cpp b/src/devices/sound/ym2151.cpp
index 82481fb79e4..b519d9a1224 100644
--- a/src/devices/sound/ym2151.cpp
+++ b/src/devices/sound/ym2151.cpp
@@ -1846,7 +1846,7 @@ void ym2151_device::sound_stream_update(sound_stream &stream, std::vector<read_s
}
constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- while (!outputs[0].done())
+ for (int sampindex=0; sampindex<outputs[0].samples(); sampindex++)
{
advance_eg();
@@ -1872,8 +1872,8 @@ void ym2151_device::sound_stream_update(sound_stream &stream, std::vector<read_s
outr = 32767;
else if (outr < -32768)
outr = -32768;
- outputs[0].put(stream_buffer::sample_t(outl) * sample_scale);
- outputs[1].put(stream_buffer::sample_t(outr) * sample_scale);
+ outputs[0].put(sampindex, stream_buffer::sample_t(outl) * sample_scale);
+ outputs[1].put(sampindex, stream_buffer::sample_t(outr) * sample_scale);
advance();
}
diff --git a/src/devices/video/i8244.cpp b/src/devices/video/i8244.cpp
index 3d7ca031a6e..8288dd9e552 100644
--- a/src/devices/video/i8244.cpp
+++ b/src/devices/video/i8244.cpp
@@ -745,11 +745,11 @@ void i8244_device::sound_stream_update(sound_stream &stream, std::vector<read_st
u8 volume = m_vdc.s.sound & 0xf;
stream_buffer::sample_t sample_on = (m_sh_output & m_vdc.s.sound >> 7) * 0.5;
- while (!outputs[0].done())
+ for (int i = 0; i < outputs[0].samples(); i++)
{
// clock duty cycle
m_sh_duty = (m_sh_duty + 1) & 0xf;
- outputs[0].put((m_sh_duty < volume) ? sample_on : 0.0);
+ outputs[0].put(i, (m_sh_duty < volume) ? sample_on : 0.0);
}
}
diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp
index 1e7be43b32f..29d8b4e13b5 100644
--- a/src/emu/disound.cpp
+++ b/src/emu/disound.cpp
@@ -512,9 +512,9 @@ void device_mixer_interface::sound_stream_update(sound_stream &stream, std::vect
int outputnum = m_outputmap[inputnum];
auto &output = outputs[outputnum];
if (!m_output_clear[outputnum])
- output.copy_indexed(0, input);
+ output.copy(input);
else
- output.add_indexed(0, input);
+ output.add(input);
m_output_clear[outputnum] = true;
}
@@ -522,5 +522,5 @@ void device_mixer_interface::sound_stream_update(sound_stream &stream, std::vect
// clear anything unused
for (int outputnum = 0; outputnum < m_outputs; outputnum++)
if (!m_output_clear[outputnum])
- outputs[outputnum].fill_indexed(0, 0);
+ outputs[outputnum].fill(0);
}
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp
index d2c968ca370..a00546f7af3 100644
--- a/src/emu/sound.cpp
+++ b/src/emu/sound.cpp
@@ -208,7 +208,7 @@ void stream_buffer::flush_wav()
// convert and fill
for (int sampindex = 0; sampindex < cursamples; sampindex++)
- buffer[sampindex] = s16(view.get_indexed(samplebase + sampindex) * 32768.0);
+ buffer[sampindex] = s16(view.get(samplebase + sampindex) * 32768.0);
// write to the WAV
wav_add_data_16(m_wav_file, buffer, cursamples);
@@ -743,7 +743,7 @@ read_stream_view sound_stream::update_view(attotime start, attotime end, u32 out
#if (SOUND_DEBUG)
// clear each output view to NANs before we call the callback
for (unsigned int outindex = 0; outindex < m_output.size(); outindex++)
- m_output_view[outindex].fill_indexed(0, NAN);
+ m_output_view[outindex].fill(NAN);
#endif
// if we have an extended callback, that's all we need
@@ -753,7 +753,7 @@ read_stream_view sound_stream::update_view(attotime start, attotime end, u32 out
// make sure everything was overwritten
for (unsigned int outindex = 0; outindex < m_output.size(); outindex++)
for (int sampindex = 0; sampindex < m_output_view[outindex].samples(); sampindex++)
- m_output_view[outindex].get_indexed(sampindex);
+ m_output_view[outindex].get(sampindex);
for (unsigned int outindex = 0; outindex < m_output.size(); outindex++)
m_output[outindex].m_buffer.flush_wav();
@@ -934,7 +934,7 @@ void sound_stream::stream_update_legacy(sound_stream &stream, std::vector<read_s
{
stream_sample_t *dest = inputptr[inputnum];
for (int index = 0; index < cursamples; index++)
- dest[index] = stream_sample_t(inputs[inputnum].get_indexed(baseindex + index) * stream_buffer::sample_t(32768.0));
+ dest[index] = stream_sample_t(inputs[inputnum].get(baseindex + index) * stream_buffer::sample_t(32768.0));
}
// run the callback
@@ -945,7 +945,7 @@ void sound_stream::stream_update_legacy(sound_stream &stream, std::vector<read_s
{
stream_sample_t *src = outputptr[outputnum];
for (int index = 0; index < cursamples; index++)
- outputs[outputnum].put_indexed(baseindex + index, stream_buffer::sample_t(src[index]) * stream_buffer::sample_t(1.0 / 32768.0));
+ outputs[outputnum].put(baseindex + index, stream_buffer::sample_t(src[index]) * stream_buffer::sample_t(1.0 / 32768.0));
}
}
}
@@ -1012,6 +1012,7 @@ void default_resampler_stream::resampler_sound_update(sound_stream &stream, std:
}
// if we have equal sample rates, we just need to copy
+ auto numsamples = output.samples();
if (input.sample_rate() == output.sample_rate())
{
output.copy(input);
@@ -1033,13 +1034,14 @@ void default_resampler_stream::resampler_sound_update(sound_stream &stream, std:
attotime latency = latency_samples * input.sample_period();
// clamp the latency to the start (only relevant at the beginning)
+ s32 dstindex = 0;
attotime output_start = output.start_time();
- while (latency > output_start && !output.done())
+ while (latency > output_start && dstindex < numsamples)
{
- output.put(0);
+ output.put(dstindex++, 0);
output_start += output.sample_period();
}
- if (output.done())
+ if (dstindex >= numsamples)
return;
// create a rebased input buffer around the adjusted start time
@@ -1053,14 +1055,15 @@ void default_resampler_stream::resampler_sound_update(sound_stream &stream, std:
sound_assert(srcpos <= 1.0f);
// input is undersampled: point sample except where our sample period covers a boundary
+ s32 srcindex = 0;
if (step < 1.0)
{
- stream_buffer::sample_t cursample = rebased.get();
- while (!output.done())
+ stream_buffer::sample_t cursample = rebased.get(srcindex++);
+ for ( ; dstindex < numsamples; dstindex++)
{
// if still within the current sample, just replicate
if (srcpos <= 1.0)
- output.put(cursample);
+ output.put(dstindex, cursample);
// if crossing a sample boundary, blend with the neighbor
else
@@ -1068,18 +1071,19 @@ void default_resampler_stream::resampler_sound_update(sound_stream &stream, std:
srcpos -= 1.0;
sound_assert(srcpos <= step + 1e-5);
stream_buffer::sample_t prevsample = cursample;
- cursample = rebased.get();
- output.put(stepinv * (prevsample * (step - srcpos) + srcpos * cursample));
+ cursample = rebased.get(srcindex++);
+ output.put(dstindex, stepinv * (prevsample * (step - srcpos) + srcpos * cursample));
}
srcpos += step;
}
+ sound_assert(srcindex <= rebased.samples());
}
// input is oversampled: sum the energy
else
{
- float cursample = rebased.get();
- while (!output.done())
+ float cursample = rebased.get(srcindex++);
+ for ( ; dstindex < numsamples; dstindex++)
{
// compute the partial first sample and advance
stream_buffer::sample_t scale = 1.0 - srcpos;
@@ -1089,17 +1093,18 @@ void default_resampler_stream::resampler_sound_update(sound_stream &stream, std:
stream_buffer::sample_t remaining = step - scale;
while (remaining >= 1.0)
{
- sample += rebased.get();
+ sample += rebased.get(srcindex++);
remaining -= 1.0;
}
// add in the final partial sample
- cursample = rebased.get();
+ cursample = rebased.get(srcindex++);
sample += cursample * remaining;
- output.put(sample * stepinv);
+ output.put(dstindex, sample * stepinv);
// our position is now the remainder
srcpos = remaining;
+ sound_assert(srcindex <= rebased.samples());
}
}
}
diff --git a/src/emu/sound.h b/src/emu/sound.h
index d7a833c749d..5ccc78c015b 100644
--- a/src/emu/sound.h
+++ b/src/emu/sound.h
@@ -239,7 +239,6 @@ public:
m_buffer(buffer),
m_end(end),
m_start(start),
- m_offset(0),
m_gain(gain)
{
normalize_start_end();
@@ -276,7 +275,6 @@ public:
m_start = rhs.m_start;
m_end = rhs.m_end;
m_gain = rhs.m_gain;
- m_offset = 0;
normalize_start_end();
return *this;
}
@@ -294,18 +292,6 @@ public:
// return the number of samples represented by the buffer
u32 samples() const { return m_end - m_start; }
- // return the current offset within the buffer
- s32 offset() const { return m_offset; }
-
- // return the number of samples remaining from the current offset
- s32 remaining() const { return samples() - m_offset; }
-
- // (re)set the current offset within the buffer
- read_stream_view const &reset(s32 offset = 0) const { m_offset = offset; return *this; }
-
- // return true if we've consumed all the samples in the view
- bool done() const { return m_offset >= samples(); }
-
// return the starting or ending time of the buffer
attotime start_time() const { return m_buffer->index_time(m_start); }
attotime end_time() const { return m_buffer->index_time(m_end); }
@@ -317,7 +303,7 @@ public:
read_stream_view &apply_gain(float gain) { m_gain *= gain; return *this; }
// safely fetch a gain-scaled sample from the buffer
- sample_t get_indexed(s32 index) const
+ sample_t get(s32 index) const
{
sound_assert(u32(index) < samples());
index += m_start;
@@ -328,7 +314,7 @@ public:
// safely fetch a raw sample from the buffer; if you use this, you need to
// apply the gain yourself for correctness
- sample_t getraw_indexed(s32 index) const
+ sample_t getraw(s32 index) const
{
sound_assert(u32(index) < samples());
index += m_start;
@@ -337,10 +323,6 @@ public:
return m_buffer->get(index);
}
- // non-indexed versions of the above that use the implied offset
- sample_t get() const { sound_assert(m_offset < samples()); return get_indexed(m_offset++); }
- sample_t getraw() const { sound_assert(m_offset < samples()); return getraw_indexed(m_offset++); }
-
protected:
// normalize start/end
void normalize_start_end()
@@ -356,7 +338,6 @@ protected:
stream_buffer *m_buffer; // pointer to the stream buffer we're viewing
s32 m_end; // ending sample index (always >= start)
s32 m_start; // starting sample index
- mutable s32 m_offset; // current read/write offset
sample_t m_gain; // overall gain factor
};
@@ -383,11 +364,8 @@ public:
{
}
- // (re)set the current offset within the buffer
- write_stream_view &reset(s32 offset = 0) { m_offset = offset; return *this; }
-
// safely write a gain-applied sample to the buffer
- void put_indexed(s32 index, sample_t sample)
+ void put(s32 index, sample_t sample)
{
sound_assert(u32(index) < samples());
index += m_start;
@@ -397,7 +375,7 @@ public:
}
// safely add a gain-applied sample to the buffer
- void add_indexed(s32 index, sample_t sample)
+ void add(s32 index, sample_t sample)
{
sound_assert(u32(index) < samples());
index += m_start;
@@ -407,9 +385,9 @@ public:
}
// fill part of the view with the given value
- s32 fill_indexed(s32 start, sample_t value, s32 count = -1)
+ void fill(sample_t value, s32 start, s32 count)
{
- if (count < 0 || start + count > samples())
+ if (start + count > samples())
count = samples() - start;
u32 index = start + m_start;
for (s32 sampindex = 0; sampindex < count; sampindex++)
@@ -417,51 +395,39 @@ public:
m_buffer->put(index, value);
index = m_buffer->next_index(index);
}
- return count;
}
+ void fill(sample_t value, s32 start) { fill(value, start, samples() - start); }
+ void fill(sample_t value) { fill(value, 0, samples()); }
// copy data from another view
- s32 copy_indexed(s32 start, read_stream_view const &src, s32 srcstart = -1, s32 count = -1)
+ void copy(read_stream_view const &src, s32 start, s32 count)
{
- if (count < 0 || start + count > samples())
+ if (start + count > samples())
count = samples() - start;
- if (srcstart < 0)
- srcstart = start;
- if (srcstart + count > src.samples())
- count = src.samples() - srcstart;
u32 index = start + m_start;
for (s32 sampindex = 0; sampindex < count; sampindex++)
{
- m_buffer->put(index, src.get_indexed(srcstart + sampindex));
+ m_buffer->put(index, src.get(start + sampindex));
index = m_buffer->next_index(index);
}
- return count;
}
+ void copy(read_stream_view const &src, s32 start) { copy(src, start, samples() - start); }
+ void copy(read_stream_view const &src) { copy(src, 0, samples()); }
// add data from another view to our current values
- s32 add_indexed(s32 start, read_stream_view const &src, s32 srcstart = -1, s32 count = -1)
+ void add(read_stream_view const &src, s32 start, s32 count)
{
- if (count < 0 || start + count > samples())
+ if (start + count > samples())
count = samples() - start;
- if (srcstart < 0)
- srcstart = start;
- if (srcstart + count > src.samples())
- count = src.samples() - srcstart;
u32 index = start + m_start;
for (s32 sampindex = 0; sampindex < count; sampindex++)
{
- m_buffer->put(index, m_buffer->get(index) + src.get_indexed(start + sampindex));
+ m_buffer->put(index, m_buffer->get(index) + src.get(start + sampindex));
index = m_buffer->next_index(index);
}
- return count;
}
-
- // non-indexed versions of the above that use the implied offset
- void put(sample_t sample) { sound_assert(m_offset < samples()); put_indexed(m_offset++, sample); }
- void add(sample_t sample) { sound_assert(m_offset < samples()); add_indexed(m_offset++, sample); }
- s32 fill(sample_t value, s32 count = -1) { m_offset += count = fill_indexed(m_offset, value, count); return count; }
- s32 copy(read_stream_view const &src, s32 count = -1) { count = copy_indexed(m_offset, src, m_offset, count); m_offset += count; src.reset(src.offset() + count); return count; }
- s32 add(read_stream_view const &src, s32 count = -1) { count = add_indexed(m_offset, src, m_offset, count); m_offset += count; src.reset(src.offset() + count); return count; }
+ void add(read_stream_view const &src, s32 start) { add(src, start, samples() - start); }
+ void add(read_stream_view const &src) { add(src, 0, samples()); }
};
diff --git a/src/emu/speaker.cpp b/src/emu/speaker.cpp
index b487b5d8aea..3cbb14355a4 100644
--- a/src/emu/speaker.cpp
+++ b/src/emu/speaker.cpp
@@ -74,9 +74,9 @@ void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample
if (machine().options().speaker_report() != 0)
{
u32 samples_per_bucket = m_mixer_stream->sample_rate() / BUCKETS_PER_SECOND;
- while (!view.done())
+ for (int sample = 0; sample < expected_samples; sample++)
{
- m_current_max = std::max(m_current_max, fabsf(view.get()));
+ m_current_max = std::max(m_current_max, fabsf(view.get(sample)));
if (++m_samples_this_bucket >= samples_per_bucket)
{
m_max_sample.push_back(m_current_max);
@@ -84,7 +84,6 @@ void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample
m_samples_this_bucket = 0;
}
}
- view.reset();
}
// mix if sound is enabled
@@ -94,7 +93,7 @@ void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample
if (m_x == 0)
for (int sample = 0; sample < expected_samples; sample++)
{
- stream_buffer::sample_t cursample = view.get();
+ stream_buffer::sample_t cursample = view.get(sample);
leftmix[sample] += cursample;
rightmix[sample] += cursample;
}
@@ -102,12 +101,12 @@ void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample
// if the speaker is to the left, send only to the left
else if (m_x < 0)
for (int sample = 0; sample < expected_samples; sample++)
- leftmix[sample] += view.get();
+ leftmix[sample] += view.get(sample);
// if the speaker is to the right, send only to the right
else
for (int sample = 0; sample < expected_samples; sample++)
- rightmix[sample] += view.get();
+ rightmix[sample] += view.get(sample);
}
}
diff --git a/src/mame/audio/sente6vb.cpp b/src/mame/audio/sente6vb.cpp
index 311f8929c17..22c9721a18a 100644
--- a/src/mame/audio/sente6vb.cpp
+++ b/src/mame/audio/sente6vb.cpp
@@ -98,9 +98,9 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override
{
- while (!outputs[0].done())
+ for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++)
{
- outputs[0].put(BIT(m_noise_state, 0) ? 1.0 : 0.0);
+ outputs[0].put(sampindex, BIT(m_noise_state, 0) ? 1.0 : 0.0);
m_noise_state = (m_noise_state >> 1) | ((BIT(m_noise_state, 0) ^ BIT(m_noise_state, 3)) << 16);
}
}