flt_vol: fix regressions, apply_gain takes effect too early so do it it in a loop like how it was before

This commit is contained in:
hap 2022-05-22 19:06:16 +02:00
parent 034e0d2c87
commit 87a1e2cc2e

View File

@ -11,8 +11,8 @@ DEFINE_DEVICE_TYPE(FILTER_VOLUME, filter_volume_device, "filter_volume", "Volume
// filter_volume_device - constructor // filter_volume_device - constructor
//------------------------------------------------- //-------------------------------------------------
filter_volume_device::filter_volume_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) filter_volume_device::filter_volume_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
: device_t(mconfig, FILTER_VOLUME, tag, owner, clock), device_t(mconfig, FILTER_VOLUME, tag, owner, clock),
device_sound_interface(mconfig, *this), device_sound_interface(mconfig, *this),
m_stream(nullptr), m_stream(nullptr),
m_gain(0) m_gain(0)
@ -26,8 +26,10 @@ filter_volume_device::filter_volume_device(const machine_config &mconfig, const
void filter_volume_device::device_start() void filter_volume_device::device_start()
{ {
m_gain = 0x100; m_gain = 1.0;
m_stream = stream_alloc(1, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE); m_stream = stream_alloc(1, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE);
save_item(NAME(m_gain));
} }
@ -37,13 +39,11 @@ void filter_volume_device::device_start()
void filter_volume_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) void filter_volume_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{ {
// no need to work here; just copy input stream to output and apply gain for (int i = 0; i < outputs[0].samples(); i++)
outputs[0] = inputs[0]; outputs[0].put(i, inputs[0].get(i) * m_gain);
outputs[0].apply_gain(m_gain);
} }
void filter_volume_device::flt_volume_set_volume(float volume) void filter_volume_device::flt_volume_set_volume(float volume)
{ {
m_stream->update(); m_stream->update();