diff options
-rw-r--r-- | src/frontend/mame/ui/audiomix.cpp | 103 | ||||
-rw-r--r-- | src/frontend/mame/ui/audiomix.h | 6 |
2 files changed, 45 insertions, 64 deletions
diff --git a/src/frontend/mame/ui/audiomix.cpp b/src/frontend/mame/ui/audiomix.cpp index 9d9a3eeaa99..75b5ee334d5 100644 --- a/src/frontend/mame/ui/audiomix.cpp +++ b/src/frontend/mame/ui/audiomix.cpp @@ -47,6 +47,10 @@ bool menu_audio_mixer::handle(event const *ev) return false; } + bool const alt_pressed = machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT); + bool const ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL); + bool const shift_pressed = machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT); + switch(ev->iptkey) { case IPT_UI_MIXER_ADD_FULL: if(m_current_selection.m_maptype == MT_INTERNAL) @@ -264,18 +268,32 @@ bool menu_audio_mixer::handle(event const *ev) } case GRP_DB: { - double db = dec_db(m_current_selection.m_db); - m_current_selection.m_db = db; + if(shift_pressed) + m_current_selection.m_db -= 0.1f; + else if(ctrl_pressed) + m_current_selection.m_db -= 10.0f; + else if(alt_pressed) { + if(m_current_selection.m_db > 0.0f) + m_current_selection.m_db = 0.0f; + else + m_current_selection.m_db = -96.0f; + } + else + m_current_selection.m_db -= 1.0f; + + m_current_selection.m_db = floorf(m_current_selection.m_db * 10.0f) / 10.0f; + m_current_selection.m_db = std::clamp(m_current_selection.m_db, -96.0f, 12.0f); + if(m_current_selection.m_maptype == MT_FULL) { if(m_current_selection.m_node == 0) - machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, db); + machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, m_current_selection.m_db); else - machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), db); + machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), m_current_selection.m_db); } else { if(m_current_selection.m_node == 0) - machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, db); + machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); else - machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, db); + machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, m_current_selection.m_db); } m_generation --; return true; @@ -391,18 +409,32 @@ bool menu_audio_mixer::handle(event const *ev) } case GRP_DB: { - double db = inc_db(m_current_selection.m_db); - m_current_selection.m_db = db; + if(shift_pressed) + m_current_selection.m_db += 0.1f; + else if(ctrl_pressed) + m_current_selection.m_db += 10.0f; + else if(alt_pressed) { + if(m_current_selection.m_db < 0.0f) + m_current_selection.m_db = 0.0f; + else + m_current_selection.m_db = 12.0f; + } + else + m_current_selection.m_db += 1.0f; + + m_current_selection.m_db = floorf(m_current_selection.m_db * 10.0f) / 10.0f; + m_current_selection.m_db = std::clamp(m_current_selection.m_db, -96.0f, 12.0f); + if(m_current_selection.m_maptype == MT_FULL) { if(m_current_selection.m_node == 0) - machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, db); + machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, m_current_selection.m_db); else - machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), db); + machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), m_current_selection.m_db); } else { if(m_current_selection.m_node == 0) - machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, db); + machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); else - machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, db); + machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, m_current_selection.m_db); } m_generation --; return true; @@ -1017,52 +1049,5 @@ uint32_t menu_audio_mixer::find_previous_available_channel_node(sound_io_device } } -float menu_audio_mixer::quantize_db(float db) -{ - if(db >= 12.0) - return 12.0; - if(db >= -12.0) - return floor(db*2 + 0.5) / 2; - if(db >= -24.0) - return floor(db + 0.5); - if(db >= -48.0) - return floor(db/2 + 0.5) * 2; - if(db >= -96.0) - return floor(db/4 + 0.5) * 4; - return -96.0; -} - -float menu_audio_mixer::inc_db(float db) -{ - db = quantize_db(db); - if(db >= 12) - return 12.0; - if(db >= -12.0) - return db + 0.5; - if(db >= -24.0) - return db + 1; - if(db >= -48.0) - return db + 2; - if(db >= -96.0 + 4) - return db + 4; - return -96.0 + 4; -} - -float menu_audio_mixer::dec_db(float db) -{ - db = quantize_db(db); - if(db >= 12.5) - return 11.5; - if(db > -12.0) - return db - 0.5; - if(db > -24.0) - return db - 1; - if(db > -48.0) - return db - 2; - if(db >= -92.0) - return db - 4; - return -96.0; -} - } // namespace ui diff --git a/src/frontend/mame/ui/audiomix.h b/src/frontend/mame/ui/audiomix.h index 880b4829782..5f8468f01f0 100644 --- a/src/frontend/mame/ui/audiomix.h +++ b/src/frontend/mame/ui/audiomix.h @@ -63,7 +63,7 @@ private: select_entry m_current_selection; uint32_t m_current_group; std::vector<select_entry> m_selections; - + virtual void populate() override; virtual bool handle(event const *ev) override; @@ -88,10 +88,6 @@ private: uint32_t find_previous_available_node(sound_io_device *dev, uint32_t node) const; uint32_t find_next_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const; uint32_t find_previous_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const; - - static float quantize_db(float db); - static float inc_db(float db); - static float dec_db(float db); }; } // namespace ui |