From cef6157803320544651bfc96457d2f8a6df0abd6 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Mon, 14 Apr 2025 11:31:53 +0200 Subject: New sound infrastructure. Should be added soon: - mute - lua hookup (with documentation) - speaker/microphone resampling To be added a little later: - compression - reverb Needs to be added by someone else: - coreaudio - direct - portaudio - xaudio2 - js --- src/devices/sound/uda1344.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/devices/sound/uda1344.cpp') diff --git a/src/devices/sound/uda1344.cpp b/src/devices/sound/uda1344.cpp index b8d445ef3b8..3031ea2e75d 100644 --- a/src/devices/sound/uda1344.cpp +++ b/src/devices/sound/uda1344.cpp @@ -88,25 +88,21 @@ void uda1344_device::device_reset() memset(m_bufout, 0, sizeof(uint32_t) * 2); } -void uda1344_device::sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) +void uda1344_device::sound_stream_update(sound_stream &stream) { - for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + for (int channel = 0; channel < 2 && channel < stream.output_count(); channel++) { - auto &output = outputs[channel]; uint32_t curout = m_bufout[channel]; uint32_t curin = m_bufin[channel]; // feed as much as we can int sampindex; - for (sampindex = 0; curout != curin && sampindex < output.samples(); sampindex++) + for (sampindex = 0; curout != curin && sampindex < stream.samples(); sampindex++) { - output.put(sampindex, stream_buffer::sample_t(m_buffer[channel][curout]) * m_volume); + stream.put(channel, sampindex, sound_stream::sample_t(m_buffer[channel][curout]) * m_volume); curout = (curout + 1) % BUFFER_SIZE; } - // fill the rest with silence - output.fill(0, sampindex); - // save the new output pointer m_bufout[channel] = curout; } @@ -116,8 +112,8 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) { const int16_t samples[2] = { left, right }; - const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + const sound_stream::sample_t sample_scale = 1.0 / 32768.0; + const sound_stream::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; m_stream->update(); @@ -126,7 +122,7 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) int maxin = (m_bufout[channel] + BUFFER_SIZE - 1) % BUFFER_SIZE; if (m_bufin[channel] != maxin) { - m_buffer[channel][m_bufin[channel]] = stream_buffer::sample_t(samples[channel]) * sample_scale * enable_scale; + m_buffer[channel][m_bufin[channel]] = sound_stream::sample_t(samples[channel]) * sample_scale * enable_scale; m_bufin[channel] = (m_bufin[channel] + 1) % BUFFER_SIZE; } else -- cgit v1.2.3-70-g09d2