mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
sound: Improved view interfaces to match usage patterns
* read/write_stream_views now have an internal index * get/put/add/fill/copy now implicitly use and advance this index * new method reset() can (re)set the internal index * new method done() checks if index is past the end * new method remaining() indicates how many samples remain * get_indexed/put_indexed/etc available for random access * updated all consumers to new interfaces
This commit is contained in:
parent
4118f19c48
commit
dc0ede3c90
@ -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(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;
|
||||
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;
|
||||
|
||||
stream_buffer::sample_t out_scale = 1.0 / (32768.0 * 65536.0);
|
||||
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);
|
||||
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);
|
||||
|
||||
sync_w(1);
|
||||
}
|
||||
|
@ -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;
|
||||
for (sampindex = 0; sampindex < m_buffer.size(); sampindex++)
|
||||
target.put(sampindex, m_buffer[sampindex]);
|
||||
target.fill(m_cur, sampindex);
|
||||
int sampindex = 0;
|
||||
while (!target.done() && sampindex < m_buffer.size())
|
||||
target.put(m_buffer[sampindex++]);
|
||||
target.fill(m_cur);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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(index); }
|
||||
stream_buffer::sample_t operator[](std::size_t index) { return get_indexed(index); }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
for (int s = 0; s < bufl.samples(); ++s)
|
||||
while (!bufl.done())
|
||||
{
|
||||
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(s) * 32767.0);
|
||||
m_DSP.EXTS[i] = s16(inputs[i].get() * 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(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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 i, ch;
|
||||
int 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;
|
||||
for (i = 0; i < outL.samples(); i++)
|
||||
while (!outL.done())
|
||||
{
|
||||
int8_t smpll, smplr;
|
||||
|
||||
@ -234,8 +234,8 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre
|
||||
break;
|
||||
}
|
||||
|
||||
outL.put(i, stream_buffer::sample_t(smpll) * sample_scale);
|
||||
outR.put(i, stream_buffer::sample_t(smplr) * sample_scale);
|
||||
outL.put(stream_buffer::sample_t(smpll) * sample_scale);
|
||||
outR.put(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);
|
||||
for (i = 0; i < outL.samples(); i++)
|
||||
while (!outL.done())
|
||||
{
|
||||
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(i, stream_buffer::sample_t(mixL) * sample_scale);
|
||||
outR.put(i, stream_buffer::sample_t(mixR) * sample_scale);
|
||||
outL.put(stream_buffer::sample_t(mixL) * sample_scale);
|
||||
outR.put(stream_buffer::sample_t(mixR) * sample_scale);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -144,14 +144,13 @@ 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;
|
||||
for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time)
|
||||
while (!dest.done())
|
||||
{
|
||||
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<int>(dest.samples() - sampindex, 256 - master_count);
|
||||
samples_this_time = std::min(samples_this_time, 64 - noise_clock);
|
||||
samples_this_time = std::min(256 - master_count, 64 - noise_clock);
|
||||
|
||||
/* sum the output of the tone generators */
|
||||
if (m_a_state)
|
||||
@ -166,7 +165,7 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<
|
||||
cursample += m_reg[7] >> 4;
|
||||
|
||||
/* scale to max and output */
|
||||
dest.fill(stream_buffer::sample_t(cursample) * sample_scale, sampindex, samples_this_time);
|
||||
samples_this_time = dest.fill(stream_buffer::sample_t(cursample) * sample_scale, samples_this_time);
|
||||
|
||||
/* clock the noise; a 2-bit counter clocks a 4-bit counter which clocks the LFSR */
|
||||
noise_clock += samples_this_time;
|
||||
|
@ -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)
|
||||
{
|
||||
for (int i = 0; i < outL.samples(); i++)
|
||||
while (!outL.done())
|
||||
{
|
||||
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);
|
||||
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);
|
||||
m_play_ptr += 4;
|
||||
}
|
||||
|
||||
|
@ -1086,12 +1086,10 @@ 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 < m_streams; chan++)
|
||||
for (int chan = 0; chan < outputs.size(); chan++)
|
||||
outputs[chan].fill(0);
|
||||
}
|
||||
|
||||
@ -1103,7 +1101,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 */
|
||||
for (int sampindex = 0; sampindex < samples; sampindex++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
for (int chan = 0; chan < NUM_CHANNELS; chan++)
|
||||
{
|
||||
@ -1199,38 +1197,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(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
outputs[chan].put(m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
else
|
||||
outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
|
||||
outputs[chan].put(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(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
else
|
||||
outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
|
||||
outputs[chan].put(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(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]);
|
||||
else
|
||||
outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
|
||||
outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_expanded_mode())
|
||||
outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
|
||||
outputs[chan].put(m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
|
||||
else
|
||||
outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
|
||||
outputs[chan].put(m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputs[0].put(sampindex, mix_3D());
|
||||
outputs[0].put(mix_3D());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_str
|
||||
}
|
||||
|
||||
/* fill in the sample */
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
buffer.put(sampindex, signal);
|
||||
buffer.put(signal);
|
||||
incr -= clock;
|
||||
while( incr < 0 )
|
||||
{
|
||||
|
@ -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;
|
||||
for (int i = 0; i < samples; i++)
|
||||
while (!dest1.done())
|
||||
{
|
||||
stream_buffer::sample_t val;
|
||||
|
||||
val = stream_buffer::sample_t(*lmix++) * sample_scale;
|
||||
dest1.put(i, limit(val));
|
||||
dest1.put(limit(val));
|
||||
val = stream_buffer::sample_t(*rmix++) * sample_scale;
|
||||
dest2.put(i, limit(val));
|
||||
dest2.put(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;
|
||||
for (int i = 0; i < samples; i++)
|
||||
while (!dest1.done())
|
||||
{
|
||||
stream_buffer::sample_t val;
|
||||
|
||||
val = stream_buffer::sample_t(*lmix++) * sample_scale;
|
||||
dest1.put(i, limit(val));
|
||||
dest1.put(limit(val));
|
||||
val = stream_buffer::sample_t(*rmix++) * sample_scale;
|
||||
dest2.put(i, limit(val));
|
||||
dest2.put(limit(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
for (int i = 0; i < buffer_fl.samples(); i++)
|
||||
while (!buffer_fl.done())
|
||||
{
|
||||
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(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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,10 @@ 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)
|
||||
{
|
||||
@ -77,7 +81,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
|
||||
{
|
||||
/* Noise mode */
|
||||
const u32 step = (chan->noise_control & 0x1f) ^ 0x1f;
|
||||
for (int i = 0; i < outputs[0].samples(); i += 1)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
s16 data = BIT(chan->noise_seed, 0) ? 0x1f : 0;
|
||||
chan->noise_counter--;
|
||||
@ -88,18 +92,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(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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (chan->control & 0x40)
|
||||
{
|
||||
/* DDA mode */
|
||||
for (int i = 0; i < outputs[0].samples(); i++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -112,7 +116,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;
|
||||
for (int i = 0; i < outputs[0].samples(); i += 1)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
s32 step = lfo_dstchan->frequency ? lfo_dstchan->frequency : 0x1000;
|
||||
if (m_lfo_control & 0x80) // reset LFO
|
||||
@ -138,8 +142,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(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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,7 +151,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st
|
||||
{
|
||||
/* Waveform mode */
|
||||
const u32 step = chan->frequency ? chan->frequency : 0x1000;
|
||||
for (int i = 0; i < outputs[0].samples(); i += 1)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
const s16 data = chan->waveform[chan->index];
|
||||
chan->tick--;
|
||||
@ -156,8 +160,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(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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(0);
|
||||
m_audio_volume[1] = outputs[1].get(0);
|
||||
m_audio_volume[0] = outputs[0].get_indexed(0);
|
||||
m_audio_volume[1] = outputs[1].get_indexed(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;
|
||||
for (int sampindex = 0; sampindex < bufL.samples(); )
|
||||
while (!bufL.done())
|
||||
{
|
||||
/* 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, sampindex);
|
||||
bufR.fill(0, sampindex);
|
||||
bufL.fill(0);
|
||||
bufR.fill(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int samples = bufL.samples() - sampindex;
|
||||
int samples = bufL.remaining();
|
||||
if (samples > m_audio_samples)
|
||||
{
|
||||
samples = m_audio_samples;
|
||||
@ -191,11 +191,10 @@ 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(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++;
|
||||
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++;
|
||||
}
|
||||
|
||||
sampindex += samples;
|
||||
m_audio_samples -= samples;
|
||||
|
||||
if (m_audio_samples == 0)
|
||||
|
@ -114,9 +114,9 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_
|
||||
signal = 1.0;
|
||||
}
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
buffer.put(sampindex, signal);
|
||||
buffer.put(signal);
|
||||
incr -= frequency;
|
||||
while( incr < 0 )
|
||||
{
|
||||
|
@ -279,9 +279,9 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_
|
||||
signal = 1.0;
|
||||
}
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
buffer.put(sampindex, signal);
|
||||
buffer.put(signal);
|
||||
incr -= frequency;
|
||||
while( incr < 0 )
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
buffer.put(sampindex, signal);
|
||||
buffer.put(signal);
|
||||
incr -= frequency;
|
||||
while( incr < 0 )
|
||||
{
|
||||
|
@ -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
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
// 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(sampindex);
|
||||
result += EXTERNAL_VOLUME * m_mixer_external * external.get();
|
||||
|
||||
// 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(sampindex, result * m_volume);
|
||||
buffer.put(result * m_volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
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;
|
||||
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;
|
||||
stream_buffer::sample_t const vout = vref_neg + dac_multiply<bits>(vref_pos - vref_neg, this->m_code);
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(vout);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -107,20 +107,20 @@ protected:
|
||||
{
|
||||
if (this->m_code & (1 << (bits - 1)))
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
|
||||
double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
|
||||
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_neg, this->m_code ^ ~(~0U << bits));
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(vout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
|
||||
double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
|
||||
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_pos, this->m_code);
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(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
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
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;
|
||||
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;
|
||||
stream_buffer::sample_t const vout = vref_neg + dac_multiply<bits>(vref_pos - vref_neg, this->m_code ^ (1 << (bits - 1)));
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(vout);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -154,20 +154,20 @@ protected:
|
||||
{
|
||||
if (this->m_code & (1 << (bits - 1)))
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get(samp) * this->m_gain;
|
||||
double const vref_neg = inputs[DAC_VREF_NEG_INPUT].get() * this->m_gain;
|
||||
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_neg, this->m_code ^ (1 << (bits - 1)));
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(vout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int samp = 0; samp < outputs[0].samples(); samp++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
double const vref_pos = inputs[DAC_VREF_POS_INPUT].get(samp) * this->m_gain;
|
||||
double const vref_pos = inputs[DAC_VREF_POS_INPUT].get() * this->m_gain;
|
||||
stream_buffer::sample_t const vout = dac_multiply<bits - 1>(vref_pos, this->m_code);
|
||||
outputs[0].put(samp, vout);
|
||||
outputs[0].put(vout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
for (int sampindex = 0; sampindex < buffer1.samples(); sampindex++)
|
||||
while (!buffer1.done())
|
||||
{
|
||||
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(sampindex, stream_buffer::sample_t(left_volume) * sample_scale);
|
||||
buffer2.put(sampindex, stream_buffer::sample_t(right_volume) * sample_scale);
|
||||
buffer1.put(stream_buffer::sample_t(left_volume) * sample_scale);
|
||||
buffer2.put(stream_buffer::sample_t(right_volume) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -547,26 +547,20 @@ 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(cpos != sout.samples()) {
|
||||
while (!sout.done()) {
|
||||
if(m_zero_count == 0 && m_dac_index == 128)
|
||||
digitalker_step();
|
||||
|
||||
if(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;
|
||||
m_zero_count -= sout.fill(0, m_zero_count);
|
||||
|
||||
} else if(m_dac_index != 128) {
|
||||
while(cpos != sout.samples() && m_dac_index != 128) {
|
||||
while(!sout.done() && 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 != sout.samples() && pp != m_pitch) {
|
||||
sout.put(cpos++, v);
|
||||
while(!sout.done() && pp != m_pitch) {
|
||||
sout.put(v);
|
||||
pp++;
|
||||
}
|
||||
if(pp == m_pitch) {
|
||||
@ -577,7 +571,7 @@ void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<re
|
||||
}
|
||||
|
||||
} else {
|
||||
sout.fill(0, cpos);
|
||||
sout.fill(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +118,12 @@ 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(m_outview_sample++, val * (1.0 / 32768.0));
|
||||
m_outview->put(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_sample = 0; }
|
||||
virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview->reset(); }
|
||||
private:
|
||||
write_stream_view *m_outview;
|
||||
u32 m_outview_sample;
|
||||
};
|
||||
|
||||
DISCRETE_CLASS(dso_csvlog, 0,
|
||||
@ -232,7 +231,6 @@ 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);
|
||||
|
||||
|
@ -250,10 +250,7 @@ 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(m_inview_sample) * 32768.0 * m_gain + m_offset);
|
||||
m_inview_sample++;
|
||||
}
|
||||
set_output(0, m_inview->get() * 32768.0 * m_gain + m_offset);
|
||||
else
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
@ -1079,7 +1079,6 @@ 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 */
|
||||
|
@ -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;
|
||||
for(int sample = 0; sample != outputs[0].samples(); sample++) {
|
||||
while (!outputs[0].done()) {
|
||||
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(sample, stream_buffer::sample_t(lval) * sample_scale);
|
||||
outputs[1].put(sample, stream_buffer::sample_t(rval) * sample_scale);
|
||||
outputs[0].put(stream_buffer::sample_t(lval) * sample_scale);
|
||||
outputs[1].put(stream_buffer::sample_t(rval) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
buffer.add(sampindex, stream_buffer::sample_t(wave[WAVEFORM_POSITION(counter)]) * sample_scale);
|
||||
buffer.add(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];
|
||||
auto &rmix = outputs[1];
|
||||
auto &lmix = outputs[0].reset();
|
||||
auto &rmix = outputs[1].reset();
|
||||
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(i, stream_buffer::sample_t(l_noise_data) * sample_scale);
|
||||
rmix.add(i, stream_buffer::sample_t(r_noise_data) * sample_scale);
|
||||
lmix.add(stream_buffer::sample_t(l_noise_data) * sample_scale);
|
||||
rmix.add(stream_buffer::sample_t(r_noise_data) * sample_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
lmix.add(i, stream_buffer::sample_t(-l_noise_data) * sample_scale);
|
||||
rmix.add(i, stream_buffer::sample_t(-r_noise_data) * sample_scale);
|
||||
lmix.add(stream_buffer::sample_t(-l_noise_data) * sample_scale);
|
||||
rmix.add(stream_buffer::sample_t(-r_noise_data) * sample_scale);
|
||||
}
|
||||
|
||||
if (hold)
|
||||
@ -779,6 +779,7 @@ 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)
|
||||
{
|
||||
@ -791,17 +792,16 @@ 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 */
|
||||
for (i = 0; i < buffer.samples(); i++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
int cnt;
|
||||
|
||||
if (voice->noise_state)
|
||||
buffer.add(i, stream_buffer::sample_t(noise_data) * sample_scale);
|
||||
buffer.add(stream_buffer::sample_t(noise_data) * sample_scale);
|
||||
else
|
||||
buffer.add(i, stream_buffer::sample_t(-noise_data) * sample_scale);
|
||||
buffer.add(stream_buffer::sample_t(-noise_data) * sample_scale);
|
||||
|
||||
if (hold)
|
||||
{
|
||||
|
@ -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]);
|
||||
elem.generate_adpcm(*this, outputs[0].reset());
|
||||
}
|
||||
|
||||
|
||||
@ -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(sampindex, m_adpcm.clock(nibble) * sample_scale * m_volume);
|
||||
buffer.add(m_adpcm.clock(nibble) * sample_scale * m_volume);
|
||||
|
||||
// next!
|
||||
if (++m_sample >= m_count)
|
||||
|
@ -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());
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
/* store sum of output signals into the buffer */
|
||||
m_out_filter += (V0 - m_out_filter) * mult;
|
||||
buffer.put(sampindex, m_out_filter);
|
||||
buffer.put(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());
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
/* store sum of output signals into the buffer */
|
||||
m_out_filter += (V0 - m_out_filter) * mult;
|
||||
buffer.put(sampindex, m_out_filter);
|
||||
buffer.put(m_out_filter);
|
||||
}
|
||||
}
|
||||
else if (m_output_type == DISCRETE_VAR_R)
|
||||
|
@ -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;
|
||||
|
||||
for (int sampindex = 0; sampindex < buffer.samples(); sampindex++)
|
||||
while (!buffer.done())
|
||||
{
|
||||
// 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(sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2));
|
||||
buffer.put(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, sampindex);
|
||||
buffer.fill(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
for (int sampindex = 0; sampindex < lbuffer->samples(); sampindex++)
|
||||
while (!lbuffer->done())
|
||||
{
|
||||
// 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(sampindex, stream_buffer::sample_t(out) * sample_scale);
|
||||
lbuffer->put(stream_buffer::sample_t(out) * sample_scale);
|
||||
if (m_stereo)
|
||||
rbuffer->put(sampindex, stream_buffer::sample_t(out2) * sample_scale);
|
||||
rbuffer->put(stream_buffer::sample_t(out2) * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
for (int sampindex = 0; sampindex < output.samples(); sampindex++)
|
||||
output.put(sampindex, stream_buffer::sample_t(next()) * sample_scale);
|
||||
while (!output.done())
|
||||
output.put(stream_buffer::sample_t(next()) * sample_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int sampindex = 0; sampindex < output.samples(); )
|
||||
while (!output.done())
|
||||
{
|
||||
// see where we're at in the current PWM cycle
|
||||
if (m_pwm_index >= PWM_CLOCKS)
|
||||
@ -291,14 +291,8 @@ 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
|
||||
while (remaining-- != 0)
|
||||
outputs[0].put(sampindex++, value);
|
||||
m_pwm_index += outputs[0].fill(value, remaining);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
for (int sampindex = 0; sampindex < buffer8.samples(); sampindex++)
|
||||
while (!buffer8.done())
|
||||
{
|
||||
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(sampindex, sum8);
|
||||
buffer16.put(sampindex, sum16);
|
||||
buffer8.put(sum8);
|
||||
buffer16.put(sum16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
for (int sampindex = 0; sampindex < output.samples(); )
|
||||
while (!output.done())
|
||||
{
|
||||
int length = (output.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.samples();
|
||||
int length = (output.remaining() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.remaining();
|
||||
|
||||
/* generate the samples and copy to the target buffer */
|
||||
process(sample_data, length);
|
||||
for (int index = 0; index < length; index++)
|
||||
output.put(sampindex++, sample_data[index] * sample_scale);
|
||||
output.put(sample_data[index] * sample_scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,12 +738,11 @@ 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)
|
||||
for ( ; index < outputs[0].samples(); index++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
/* store the current sample */
|
||||
outputs[0].put(index, sample);
|
||||
outputs[0].put(sample);
|
||||
|
||||
/* advance by the number of clocks/output sample */
|
||||
pos += step;
|
||||
@ -775,8 +774,7 @@ void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_
|
||||
}
|
||||
|
||||
/* if we got out early, just zap the rest of the buffer */
|
||||
for (; index < outputs[0].samples(); index++)
|
||||
outputs[0].put(index, 0);
|
||||
outputs[0].fill(0);
|
||||
|
||||
/* flush the state back */
|
||||
m_clocks_left = clocks_left;
|
||||
|
@ -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
|
||||
for (int pos = 0; pos < outputs[0].samples(); pos++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
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(pos) * 0.5f;
|
||||
const float sample = outputs[i].get() * 0.5f;
|
||||
m_audio_buf[m_audio_fill_index][i][m_audio_count[m_audio_fill_index]] = sample + 0.5f;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
for(int i=0; i<outputs[0].samples(); i++) {
|
||||
while (!outputs[0].done()) {
|
||||
m_sample_count++;
|
||||
if(m_sample_count & 1)
|
||||
chip_update();
|
||||
outputs[0].put(i, analog_calc());
|
||||
outputs[0].put(analog_calc());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
for (int sampindex=0; sampindex<outputs[0].samples(); sampindex++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
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(sampindex, stream_buffer::sample_t(outl) * sample_scale);
|
||||
outputs[1].put(sampindex, stream_buffer::sample_t(outr) * sample_scale);
|
||||
outputs[0].put(stream_buffer::sample_t(outl) * sample_scale);
|
||||
outputs[1].put(stream_buffer::sample_t(outr) * sample_scale);
|
||||
|
||||
advance();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
for (int i = 0; i < outputs[0].samples(); i++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
// clock duty cycle
|
||||
m_sh_duty = (m_sh_duty + 1) & 0xf;
|
||||
outputs[0].put(i, (m_sh_duty < volume) ? sample_on : 0.0);
|
||||
outputs[0].put((m_sh_duty < volume) ? sample_on : 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(input);
|
||||
output.copy_indexed(0, input);
|
||||
else
|
||||
output.add(input);
|
||||
output.add_indexed(0, 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(0);
|
||||
outputs[outputnum].fill_indexed(0, 0);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ void stream_buffer::flush_wav()
|
||||
|
||||
// convert and fill
|
||||
for (int sampindex = 0; sampindex < cursamples; sampindex++)
|
||||
buffer[sampindex] = s16(view.get(samplebase + sampindex) * 32768.0);
|
||||
buffer[sampindex] = s16(view.get_indexed(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(NAN);
|
||||
m_output_view[outindex].fill_indexed(0, 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(sampindex);
|
||||
m_output_view[outindex].get_indexed(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(baseindex + index) * stream_buffer::sample_t(32768.0));
|
||||
dest[index] = stream_sample_t(inputs[inputnum].get_indexed(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(baseindex + index, stream_buffer::sample_t(src[index]) * stream_buffer::sample_t(1.0 / 32768.0));
|
||||
outputs[outputnum].put_indexed(baseindex + index, stream_buffer::sample_t(src[index]) * stream_buffer::sample_t(1.0 / 32768.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1012,7 +1012,6 @@ 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);
|
||||
@ -1034,14 +1033,13 @@ 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 && dstindex < numsamples)
|
||||
while (latency > output_start && !output.done())
|
||||
{
|
||||
output.put(dstindex++, 0);
|
||||
output.put(0);
|
||||
output_start += output.sample_period();
|
||||
}
|
||||
if (dstindex >= numsamples)
|
||||
if (output.done())
|
||||
return;
|
||||
|
||||
// create a rebased input buffer around the adjusted start time
|
||||
@ -1055,15 +1053,14 @@ 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(srcindex++);
|
||||
for ( ; dstindex < numsamples; dstindex++)
|
||||
stream_buffer::sample_t cursample = rebased.get();
|
||||
while (!output.done())
|
||||
{
|
||||
// if still within the current sample, just replicate
|
||||
if (srcpos <= 1.0)
|
||||
output.put(dstindex, cursample);
|
||||
output.put(cursample);
|
||||
|
||||
// if crossing a sample boundary, blend with the neighbor
|
||||
else
|
||||
@ -1071,19 +1068,18 @@ 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(srcindex++);
|
||||
output.put(dstindex, stepinv * (prevsample * (step - srcpos) + srcpos * cursample));
|
||||
cursample = rebased.get();
|
||||
output.put(stepinv * (prevsample * (step - srcpos) + srcpos * cursample));
|
||||
}
|
||||
srcpos += step;
|
||||
}
|
||||
sound_assert(srcindex <= rebased.samples());
|
||||
}
|
||||
|
||||
// input is oversampled: sum the energy
|
||||
else
|
||||
{
|
||||
float cursample = rebased.get(srcindex++);
|
||||
for ( ; dstindex < numsamples; dstindex++)
|
||||
float cursample = rebased.get();
|
||||
while (!output.done())
|
||||
{
|
||||
// compute the partial first sample and advance
|
||||
stream_buffer::sample_t scale = 1.0 - srcpos;
|
||||
@ -1093,18 +1089,17 @@ 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(srcindex++);
|
||||
sample += rebased.get();
|
||||
remaining -= 1.0;
|
||||
}
|
||||
|
||||
// add in the final partial sample
|
||||
cursample = rebased.get(srcindex++);
|
||||
cursample = rebased.get();
|
||||
sample += cursample * remaining;
|
||||
output.put(dstindex, sample * stepinv);
|
||||
output.put(sample * stepinv);
|
||||
|
||||
// our position is now the remainder
|
||||
srcpos = remaining;
|
||||
sound_assert(srcindex <= rebased.samples());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,7 @@ public:
|
||||
m_buffer(buffer),
|
||||
m_end(end),
|
||||
m_start(start),
|
||||
m_offset(0),
|
||||
m_gain(gain)
|
||||
{
|
||||
normalize_start_end();
|
||||
@ -275,6 +276,7 @@ public:
|
||||
m_start = rhs.m_start;
|
||||
m_end = rhs.m_end;
|
||||
m_gain = rhs.m_gain;
|
||||
m_offset = 0;
|
||||
normalize_start_end();
|
||||
return *this;
|
||||
}
|
||||
@ -292,6 +294,18 @@ 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); }
|
||||
@ -303,7 +317,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(s32 index) const
|
||||
sample_t get_indexed(s32 index) const
|
||||
{
|
||||
sound_assert(u32(index) < samples());
|
||||
index += m_start;
|
||||
@ -314,7 +328,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(s32 index) const
|
||||
sample_t getraw_indexed(s32 index) const
|
||||
{
|
||||
sound_assert(u32(index) < samples());
|
||||
index += m_start;
|
||||
@ -323,6 +337,10 @@ 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()
|
||||
@ -338,6 +356,7 @@ 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
|
||||
};
|
||||
|
||||
@ -364,8 +383,11 @@ 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(s32 index, sample_t sample)
|
||||
void put_indexed(s32 index, sample_t sample)
|
||||
{
|
||||
sound_assert(u32(index) < samples());
|
||||
index += m_start;
|
||||
@ -375,7 +397,7 @@ public:
|
||||
}
|
||||
|
||||
// safely add a gain-applied sample to the buffer
|
||||
void add(s32 index, sample_t sample)
|
||||
void add_indexed(s32 index, sample_t sample)
|
||||
{
|
||||
sound_assert(u32(index) < samples());
|
||||
index += m_start;
|
||||
@ -385,9 +407,9 @@ public:
|
||||
}
|
||||
|
||||
// fill part of the view with the given value
|
||||
void fill(sample_t value, s32 start, s32 count)
|
||||
s32 fill_indexed(s32 start, sample_t value, s32 count = -1)
|
||||
{
|
||||
if (start + count > samples())
|
||||
if (count < 0 || start + count > samples())
|
||||
count = samples() - start;
|
||||
u32 index = start + m_start;
|
||||
for (s32 sampindex = 0; sampindex < count; sampindex++)
|
||||
@ -395,39 +417,51 @@ 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
|
||||
void copy(read_stream_view const &src, s32 start, s32 count)
|
||||
s32 copy_indexed(s32 start, read_stream_view const &src, s32 srcstart = -1, s32 count = -1)
|
||||
{
|
||||
if (start + count > samples())
|
||||
if (count < 0 || 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(start + sampindex));
|
||||
m_buffer->put(index, src.get_indexed(srcstart + 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
|
||||
void add(read_stream_view const &src, s32 start, s32 count)
|
||||
s32 add_indexed(s32 start, read_stream_view const &src, s32 srcstart = -1, s32 count = -1)
|
||||
{
|
||||
if (start + count > samples())
|
||||
if (count < 0 || 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(start + sampindex));
|
||||
m_buffer->put(index, m_buffer->get(index) + src.get_indexed(start + sampindex));
|
||||
index = m_buffer->next_index(index);
|
||||
}
|
||||
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()); }
|
||||
|
||||
// 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; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
for (int sample = 0; sample < expected_samples; sample++)
|
||||
while (!view.done())
|
||||
{
|
||||
m_current_max = std::max(m_current_max, fabsf(view.get(sample)));
|
||||
m_current_max = std::max(m_current_max, fabsf(view.get()));
|
||||
if (++m_samples_this_bucket >= samples_per_bucket)
|
||||
{
|
||||
m_max_sample.push_back(m_current_max);
|
||||
@ -84,6 +84,7 @@ void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample
|
||||
m_samples_this_bucket = 0;
|
||||
}
|
||||
}
|
||||
view.reset();
|
||||
}
|
||||
|
||||
// mix if sound is enabled
|
||||
@ -93,7 +94,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(sample);
|
||||
stream_buffer::sample_t cursample = view.get();
|
||||
leftmix[sample] += cursample;
|
||||
rightmix[sample] += cursample;
|
||||
}
|
||||
@ -101,12 +102,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(sample);
|
||||
leftmix[sample] += view.get();
|
||||
|
||||
// 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(sample);
|
||||
rightmix[sample] += view.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++)
|
||||
while (!outputs[0].done())
|
||||
{
|
||||
outputs[0].put(sampindex, BIT(m_noise_state, 0) ? 1.0 : 0.0);
|
||||
outputs[0].put(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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user