From d0f1c15a0f6df2dd51a754cb46e6175b7079c8f2 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 - 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/vgm_visualizer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/devices/sound/vgm_visualizer.cpp') diff --git a/src/devices/sound/vgm_visualizer.cpp b/src/devices/sound/vgm_visualizer.cpp index e62ffe07785..13d25bcb6ca 100644 --- a/src/devices/sound/vgm_visualizer.cpp +++ b/src/devices/sound/vgm_visualizer.cpp @@ -54,7 +54,7 @@ DEFINE_DEVICE_TYPE(VGMVIZ, vgmviz_device, "vgmviz", "VGM Visualizer") vgmviz_device::vgmviz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, VGMVIZ, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_sound_interface(mconfig, *this) , m_screen(*this, "screen") , m_palette(*this, "palette") { @@ -76,6 +76,7 @@ vgmviz_device::~vgmviz_device() void vgmviz_device::device_start() { + stream_alloc(2, 2, machine().sample_rate()); WDL_fft_init(); fill_window(); m_bitmap.resize(SCREEN_WIDTH, SCREEN_HEIGHT); @@ -283,18 +284,19 @@ void vgmviz_device::cycle_viz_mode() // audio stream and process as necessary //------------------------------------------------- -void vgmviz_device::sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) +void vgmviz_device::sound_stream_update(sound_stream &stream) { - // call the normal interface to actually mix - device_mixer_interface::sound_stream_update(stream, inputs, outputs); + // Passthrough the audio + stream.copy(0, 0); + stream.copy(1, 1); - // now consume the outputs - for (int pos = 0; pos < outputs[0].samples(); pos++) + // now consume the inputs + for (int pos = 0; pos < stream.samples(); pos++) { - for (int i = 0; i < outputs.size(); i++) + for (int i = 0; i < stream.output_count(); 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 = stream.get(i, pos) * 0.5f; m_audio_buf[m_audio_fill_index][i][m_audio_count[m_audio_fill_index]] = sample + 0.5f; } -- cgit v1.2.3-70-g09d2