diff options
author | hap <happppp@users.noreply.github.com> | 2022-05-22 19:46:48 +0200 |
---|---|---|
committer | hap <happppp@users.noreply.github.com> | 2022-05-22 19:46:48 +0200 |
commit | e3c8b078d375c493c7bf074b8aa9620371856603 (patch) | |
tree | d444bbf7bde085b1a8157f10ec55c8875c6961da /src/mame | |
parent | 87a1e2cc2e7b8e26e3400d66d4208dc9ac3413c8 (diff) |
hh*: use flt_vol device for volume decay
Diffstat (limited to 'src/mame')
-rw-r--r-- | src/mame/drivers/hh_hmcs40.cpp | 23 | ||||
-rw-r--r-- | src/mame/drivers/hh_pic16.cpp | 46 | ||||
-rw-r--r-- | src/mame/drivers/hh_tms1k.cpp | 30 | ||||
-rw-r--r-- | src/mame/drivers/wildfire.cpp | 30 |
4 files changed, 50 insertions, 79 deletions
diff --git a/src/mame/drivers/hh_hmcs40.cpp b/src/mame/drivers/hh_hmcs40.cpp index a0deea9a9c3..347d603f2fb 100644 --- a/src/mame/drivers/hh_hmcs40.cpp +++ b/src/mame/drivers/hh_hmcs40.cpp @@ -132,6 +132,7 @@ TODO: #include "video/pwm.h" #include "machine/gen_latch.h" #include "machine/timer.h" +#include "sound/flt_vol.h" #include "sound/spkrdev.h" #include "screen.h" @@ -2403,7 +2404,8 @@ class cdkong_state : public hh_hmcs40_state { public: cdkong_state(const machine_config &mconfig, device_type type, const char *tag) : - hh_hmcs40_state(mconfig, type, tag) + hh_hmcs40_state(mconfig, type, tag), + m_volume(*this, "volume") { } void cdkong(machine_config &config); @@ -2412,15 +2414,15 @@ protected: virtual void machine_start() override; private: + required_device<filter_volume_device> m_volume; + void update_display(); void plate_w(offs_t offset, u8 data); void grid_w(u16 data); void speaker_update(); TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); - double m_speaker_volume = 0.0; - std::vector<double> m_speaker_levels; }; void cdkong_state::machine_start() @@ -2436,8 +2438,7 @@ void cdkong_state::speaker_update() if (m_r[1] & 8) m_speaker_volume = 1.0; - int level = (m_d & 8) ? 0x7fff : 0; - m_speaker->level_w(level * m_speaker_volume); + m_volume->flt_volume_set_volume(m_speaker_volume); } TIMER_DEVICE_CALLBACK_MEMBER(cdkong_state::speaker_decay_sim) @@ -2468,8 +2469,7 @@ void cdkong_state::plate_w(offs_t offset, u8 data) void cdkong_state::grid_w(u16 data) { // D3: speaker out - m_d = data; - speaker_update(); + m_speaker->level_w(BIT(data, 3)); // D4-D14: vfd grid m_grid = data >> 4 & 0x7ff; @@ -2514,15 +2514,10 @@ void cdkong_state::cdkong(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.25); + SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "volume", 0.25); + FILTER_VOLUME(config, m_volume).add_route(ALL_OUTPUTS, "mono", 1.0); TIMER(config, "speaker_decay").configure_periodic(FUNC(cdkong_state::speaker_decay_sim), attotime::from_msec(1)); - - // set volume levels (set_output_gain is too slow for sub-frame intervals) - m_speaker_levels.resize(0x8000); - for (int i = 0; i < 0x8000; i++) - m_speaker_levels[i] = double(i) / 32768.0; - m_speaker->set_levels(0x8000, &m_speaker_levels[0]); } // roms diff --git a/src/mame/drivers/hh_pic16.cpp b/src/mame/drivers/hh_pic16.cpp index dbb95babf0d..3a35e746c8c 100644 --- a/src/mame/drivers/hh_pic16.cpp +++ b/src/mame/drivers/hh_pic16.cpp @@ -60,6 +60,7 @@ TODO: #include "video/pwm.h" #include "machine/clock.h" #include "machine/timer.h" +#include "sound/flt_vol.h" #include "sound/spkrdev.h" #include "speaker.h" @@ -680,7 +681,8 @@ class flash_state : public hh_pic16_state { public: flash_state(const machine_config &mconfig, device_type type, const char *tag) : - hh_pic16_state(mconfig, type, tag) + hh_pic16_state(mconfig, type, tag), + m_volume(*this, "volume") { } void flash(machine_config &config); @@ -689,6 +691,8 @@ protected: virtual void machine_start() override; private: + required_device<filter_volume_device> m_volume; + void update_display(); void write_b(u8 data); u8 read_c(); @@ -697,7 +701,6 @@ private: void speaker_update(); TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); double m_speaker_volume = 0.0; - std::vector<double> m_speaker_levels; }; void flash_state::machine_start() @@ -714,8 +717,7 @@ void flash_state::speaker_update() m_speaker_volume = 50.0; // it takes a bit before it actually starts fading - double vol = (m_speaker_volume > 1.0) ? 1.0 : m_speaker_volume; - m_speaker->level_w(BIT(m_b, 7) * 0x7fff * vol); + m_volume->flt_volume_set_volume(std::min(m_speaker_volume, 1.0)); } TIMER_DEVICE_CALLBACK_MEMBER(flash_state::speaker_decay_sim) @@ -737,8 +739,10 @@ void flash_state::write_b(u8 data) m_b = data; update_display(); - // B6: speaker on // B7: speaker out + m_speaker->level_w(BIT(data, 7)); + + // B6: speaker on speaker_update(); } @@ -790,15 +794,10 @@ void flash_state::flash(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.25); + SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "volume", 0.25); + FILTER_VOLUME(config, m_volume).add_route(ALL_OUTPUTS, "mono", 1.0); TIMER(config, "speaker_decay").configure_periodic(FUNC(flash_state::speaker_decay_sim), attotime::from_msec(1)); - - // set volume levels (set_output_gain is too slow for sub-frame intervals) - m_speaker_levels.resize(0x8000); - for (int i = 0; i < 0x8000; i++) - m_speaker_levels[i] = double(i) / 32768.0; - m_speaker->set_levels(0x8000, &m_speaker_levels[0]); } // roms @@ -1120,7 +1119,8 @@ class leboom_state : public hh_pic16_state { public: leboom_state(const machine_config &mconfig, device_type type, const char *tag) : - hh_pic16_state(mconfig, type, tag) + hh_pic16_state(mconfig, type, tag), + m_volume(*this, "volume") { } void leboom(machine_config &config); @@ -1129,6 +1129,8 @@ protected: virtual void machine_start() override; private: + required_device<filter_volume_device> m_volume; + u8 read_a(); void write_b(u8 data); void write_c(u8 data); @@ -1136,7 +1138,6 @@ private: void speaker_update(); TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); double m_speaker_volume = 0.0; - std::vector<double> m_speaker_levels; }; void leboom_state::machine_start() @@ -1152,7 +1153,7 @@ void leboom_state::speaker_update() if (~m_c & 0x80) m_speaker_volume = 1.0; - m_speaker->level_w(BIT(m_c, 6) * 0x7fff * m_speaker_volume); + m_volume->flt_volume_set_volume(m_speaker_volume); } TIMER_DEVICE_CALLBACK_MEMBER(leboom_state::speaker_decay_sim) @@ -1177,10 +1178,12 @@ void leboom_state::write_b(u8 data) void leboom_state::write_c(u8 data) { // C4: single led - m_display->matrix(1, data >> 4 & 1); + m_display->matrix(1, BIT(data, 4)); - // C7: speaker on // C6: speaker out + m_speaker->level_w(BIT(data, 6)); + + // C7: speaker on m_c = data; speaker_update(); } @@ -1240,15 +1243,10 @@ void leboom_state::leboom(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.25); + SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "volume", 0.25); + FILTER_VOLUME(config, m_volume).add_route(ALL_OUTPUTS, "mono", 1.0); TIMER(config, "speaker_decay").configure_periodic(FUNC(leboom_state::speaker_decay_sim), attotime::from_msec(5)); - - // set volume levels (set_output_gain is too slow for sub-frame intervals) - m_speaker_levels.resize(0x8000); - for (int i = 0; i < 0x8000; i++) - m_speaker_levels[i] = double(i) / 32768.0; - m_speaker->set_levels(0x8000, &m_speaker_levels[0]); } // roms diff --git a/src/mame/drivers/hh_tms1k.cpp b/src/mame/drivers/hh_tms1k.cpp index 1d2e1b4a5b9..03faef7e99f 100644 --- a/src/mame/drivers/hh_tms1k.cpp +++ b/src/mame/drivers/hh_tms1k.cpp @@ -201,6 +201,7 @@ on Joerg Woerner's datamath.org: http://www.datamath.org/IC_List.htm #include "machine/tmc0999.h" #include "machine/tms1024.h" #include "sound/beep.h" +#include "sound/flt_vol.h" #include "sound/s14001a.h" #include "sound/sn76477.h" #include "video/hlcd0515.h" @@ -5074,6 +5075,7 @@ class mmarvin_state : public hh_tms1k_state public: mmarvin_state(const machine_config &mconfig, device_type type, const char *tag) : hh_tms1k_state(mconfig, type, tag), + m_volume(*this, "volume"), m_speed_timer(*this, "speed") { } @@ -5083,6 +5085,7 @@ protected: virtual void machine_start() override; private: + required_device<filter_volume_device> m_volume; required_device<timer_device> m_speed_timer; void update_display(); @@ -5090,10 +5093,8 @@ private: void write_o(u16 data); u8 read_k(); - void speaker_update(); TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); double m_speaker_volume = 0.0; - std::vector<double> m_speaker_levels; }; void mmarvin_state::machine_start() @@ -5104,14 +5105,9 @@ void mmarvin_state::machine_start() // handlers -void mmarvin_state::speaker_update() -{ - m_speaker->level_w(BIT(m_r, 10) * 0x7fff * m_speaker_volume); -} - TIMER_DEVICE_CALLBACK_MEMBER(mmarvin_state::speaker_decay_sim) { - speaker_update(); + m_volume->flt_volume_set_volume(m_speaker_volume); // volume decays when speaker is off, decay scale is determined by tone dial double step = (1.01 - 1.003) / 255.0; // approximation @@ -5136,17 +5132,17 @@ void mmarvin_state::write_r(u16 data) m_speed_timer->adjust(attotime::from_msec(2100 - (u8)m_inputs[4]->read() * step)); } + // R10: speaker out + m_speaker->level_w(BIT(m_r, 10)); + // R9: trigger speaker on if (m_r & 0x200 && ~data & 0x200) - m_speaker_volume = 1.0; + m_volume->flt_volume_set_volume(m_speaker_volume = 1.0); // R0,R1: digit/led select // R7: digit DP m_r = data; update_display(); - - // R10: speaker out - speaker_update(); } void mmarvin_state::write_o(u16 data) @@ -5210,16 +5206,10 @@ void mmarvin_state::mmarvin(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - SPEAKER_SOUND(config, m_speaker); - m_speaker->add_route(ALL_OUTPUTS, "mono", 0.25); + SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "volume", 0.25); + FILTER_VOLUME(config, m_volume).add_route(ALL_OUTPUTS, "mono", 1.0); TIMER(config, "speaker_decay").configure_periodic(FUNC(mmarvin_state::speaker_decay_sim), attotime::from_msec(1)); - - // set volume levels (set_output_gain is too slow for sub-frame intervals) - m_speaker_levels.resize(0x8000); - for (int i = 0; i < 0x8000; i++) - m_speaker_levels[i] = double(i) / 32768.0; - m_speaker->set_levels(0x8000, &m_speaker_levels[0]); } // roms diff --git a/src/mame/drivers/wildfire.cpp b/src/mame/drivers/wildfire.cpp index e107c30534b..a680974da95 100644 --- a/src/mame/drivers/wildfire.cpp +++ b/src/mame/drivers/wildfire.cpp @@ -37,8 +37,10 @@ TODO: *******************************************************************************/ #include "emu.h" + #include "cpu/amis2000/amis2000.h" #include "machine/timer.h" +#include "sound/flt_vol.h" #include "sound/spkrdev.h" #include "video/pwm.h" #include "speaker.h" @@ -55,7 +57,8 @@ public: driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_display(*this, "display"), - m_speaker(*this, "speaker") + m_speaker(*this, "speaker"), + m_volume(*this, "volume") { } void wildfire(machine_config &config); @@ -67,20 +70,18 @@ private: required_device<amis2000_base_device> m_maincpu; required_device<pwm_display_device> m_display; required_device<speaker_sound_device> m_speaker; + required_device<filter_volume_device> m_volume; void update_display(); void write_d(u8 data); void write_a(u16 data); - DECLARE_WRITE_LINE_MEMBER(write_f); void speaker_update(); TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); double m_speaker_volume = 0.0; - std::vector<double> m_speaker_levels; u16 m_a = 0; u8 m_d = 0; - int m_f = 0; }; void wildfire_state::machine_start() @@ -88,7 +89,6 @@ void wildfire_state::machine_start() // register for savestates save_item(NAME(m_a)); save_item(NAME(m_d)); - save_item(NAME(m_f)); save_item(NAME(m_speaker_volume)); } @@ -103,7 +103,7 @@ void wildfire_state::speaker_update() if (~m_a & 0x1000) m_speaker_volume = 1.0; - m_speaker->level_w(m_f * 0x7fff * m_speaker_volume); + m_volume->flt_volume_set_volume(m_speaker_volume); } TIMER_DEVICE_CALLBACK_MEMBER(wildfire_state::speaker_decay_sim) @@ -136,13 +136,6 @@ void wildfire_state::write_a(u16 data) speaker_update(); } -WRITE_LINE_MEMBER(wildfire_state::write_f) -{ - // F: speaker out - m_f = state; - speaker_update(); -} - /******************************************************************************* @@ -178,7 +171,7 @@ void wildfire_state::wildfire(machine_config &config) m_maincpu->read_i().set_ioport("IN.0"); m_maincpu->write_d().set(FUNC(wildfire_state::write_d)); m_maincpu->write_a().set(FUNC(wildfire_state::write_a)); - m_maincpu->write_f().set(FUNC(wildfire_state::write_f)); + m_maincpu->write_f().set(m_speaker, FUNC(speaker_sound_device::level_w)); // video hardware PWM_DISPLAY(config, m_display).set_size(12, 8); @@ -188,15 +181,10 @@ void wildfire_state::wildfire(machine_config &config) // sound hardware SPEAKER(config, "mono").front_center(); - SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.25); + SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "volume", 0.25); + FILTER_VOLUME(config, m_volume).add_route(ALL_OUTPUTS, "mono", 1.0); TIMER(config, "speaker_decay").configure_periodic(FUNC(wildfire_state::speaker_decay_sim), attotime::from_usec(100)); - - // set volume levels (set_output_gain is too slow for sub-frame intervals) - m_speaker_levels.resize(0x8000); - for (int i = 0; i < 0x8000; i++) - m_speaker_levels[i] = double(i) / 32768.0; - m_speaker->set_levels(0x8000, &m_speaker_levels[0]); } |