diff options
Diffstat (limited to 'src/devices/sound/flt_vol.cpp')
-rw-r--r-- | src/devices/sound/flt_vol.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/devices/sound/flt_vol.cpp b/src/devices/sound/flt_vol.cpp index eec55c413f8..c3f8b5f0b2e 100644 --- a/src/devices/sound/flt_vol.cpp +++ b/src/devices/sound/flt_vol.cpp @@ -11,11 +11,11 @@ DEFINE_DEVICE_TYPE(FILTER_VOLUME, filter_volume_device, "filter_volume", "Volume // filter_volume_device - constructor //------------------------------------------------- -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_sound_interface(mconfig, *this), - m_stream(nullptr), - m_gain(0) +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_sound_interface(mconfig, *this), + m_stream(nullptr), + m_gain(1.0f) { } @@ -26,8 +26,8 @@ filter_volume_device::filter_volume_device(const machine_config &mconfig, const void filter_volume_device::device_start() { - m_gain = 0x100; - m_stream = stream_alloc(1, 1, machine().sample_rate()); + m_stream = stream_alloc(1, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE); + save_item(NAME(m_gain)); } @@ -35,19 +35,18 @@ void filter_volume_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_volume_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +void filter_volume_device::sound_stream_update(sound_stream &stream) { - stream_sample_t *src = inputs[0]; - stream_sample_t *dst = outputs[0]; - - while (samples--) - *dst++ = (*src++ * m_gain) >> 8; + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * m_gain); } - -void filter_volume_device::flt_volume_set_volume(float volume) +filter_volume_device &filter_volume_device::set_gain(float gain) { - m_stream->update(); - m_gain = int(volume * 256); + if (m_stream) + m_stream->update(); + m_gain = gain; + + return *this; } |