From 53b95fea19d80e747b5b18b59b1e2139a8b5b3be Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 8 Jul 2020 20:42:45 +0200 Subject: [PATCH] audio: rename audio channels to audio downmix The setting does not actually define the channels themselves, only the downmix option that the PS3 provides. Channels might be changed seperately in the future. --- rpcs3/Emu/Audio/AudioBackend.cpp | 26 +++++++++++++------------- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 26 +++++++++++++------------- rpcs3/Emu/Cell/Modules/cellAudio.h | 4 ++-- rpcs3/Emu/system_config.h | 2 +- rpcs3/Emu/system_config_types.cpp | 12 ++++++------ rpcs3/Emu/system_config_types.h | 6 +++--- rpcs3/rpcs3qt/emu_settings.cpp | 10 +++++----- rpcs3/rpcs3qt/settings_dialog.cpp | 8 ++++---- rpcs3/rpcs3qt/settings_dialog.ui | 4 ++-- rpcs3/rpcs3qt/tooltips.h | 2 +- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/rpcs3/Emu/Audio/AudioBackend.cpp b/rpcs3/Emu/Audio/AudioBackend.cpp index 7165a6eeef..064064cc65 100644 --- a/rpcs3/Emu/Audio/AudioBackend.cpp +++ b/rpcs3/Emu/Audio/AudioBackend.cpp @@ -21,24 +21,24 @@ AudioBackend::AudioBackend() m_sampling_rate = static_cast(f32{ DEFAULT_AUDIO_SAMPLING_RATE } *sampling_rate_multiplier); } - const audio_channels channels = g_cfg.audio.audio_channel_downmix.get(); + const audio_downmix downmix = g_cfg.audio.audio_channel_downmix.get(); - switch (channels) + switch (downmix) { - case audio_channels::use_application_settings: - m_channels = 2; // TODO - break; - case audio_channels::downmix_to_stereo: - m_channels = 2; - break; - case audio_channels::downmix_to_5_1: - m_channels = 6; - break; - case audio_channels::surround_7_1: + case audio_downmix::no_downmix: m_channels = 8; break; + case audio_downmix::downmix_to_stereo: + m_channels = 2; + break; + case audio_downmix::downmix_to_5_1: + m_channels = 6; + break; + case audio_downmix::use_application_settings: + m_channels = 2; // TODO + break; default: - fmt::throw_exception("Unknown audio channel mode %s (%d)", channels, static_cast(channels)); + fmt::throw_exception("Unknown audio channel mode %s (%d)", downmix, static_cast(downmix)); } } diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 21ef35919b..887c02c2ba 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -548,7 +548,7 @@ namespace audio .convert_to_u16 = static_cast(g_cfg.audio.convert_to_u16), .start_threshold = static_cast(g_cfg.audio.start_threshold), .sampling_period_multiplier = static_cast(g_cfg.audio.sampling_period_multiplier), - .channels = g_cfg.audio.audio_channel_downmix, + .downmix = g_cfg.audio.audio_channel_downmix, .renderer = g_cfg.audio.renderer }; } @@ -568,7 +568,7 @@ namespace audio raw.convert_to_u16 != new_raw.convert_to_u16 || raw.start_threshold != new_raw.start_threshold || raw.sampling_period_multiplier != new_raw.sampling_period_multiplier || - raw.channels != new_raw.channels || + raw.downmix != new_raw.downmix || raw.renderer != new_raw.renderer) { g_audio->cfg.raw = new_raw; @@ -844,13 +844,13 @@ void cell_audio_thread::operator()() switch (cfg.audio_channels) { case 2: - mix(buf); + mix(buf); break; case 6: - mix(buf); + mix(buf); break; case 8: - mix(buf); + mix(buf); break; default: fmt::throw_exception("Unsupported number of audio channels: %u", cfg.audio_channels); @@ -867,12 +867,12 @@ void cell_audio_thread::operator()() ringbuffer.reset(); } -template +template void cell_audio_thread::mix(float *out_buffer, s32 offset) { AUDIT(out_buffer != nullptr); - constexpr u32 channels = downmix == audio_channels::surround_7_1 ? 8 : downmix == audio_channels::downmix_to_5_1 ? 6 : 2; + constexpr u32 channels = downmix == audio_downmix::no_downmix ? 8 : downmix == audio_downmix::downmix_to_5_1 ? 6 : 2; constexpr u32 out_buffer_sz = channels * AUDIO_BUFFER_SAMPLES; bool first_mix = true; @@ -924,14 +924,14 @@ void cell_audio_thread::mix(float *out_buffer, s32 offset) out_buffer[out + 0] = left; out_buffer[out + 1] = right; - if constexpr (downmix != audio_channels::downmix_to_stereo) + if constexpr (downmix != audio_downmix::downmix_to_stereo) { out_buffer[out + 2] = 0.0f; out_buffer[out + 3] = 0.0f; out_buffer[out + 4] = 0.0f; out_buffer[out + 5] = 0.0f; - if constexpr (downmix != audio_channels::downmix_to_5_1) + if constexpr (downmix != audio_downmix::downmix_to_5_1) { out_buffer[out + 6] = 0.0f; out_buffer[out + 7] = 0.0f; @@ -971,14 +971,14 @@ void cell_audio_thread::mix(float *out_buffer, s32 offset) const float side_left = buf[in + 6] * m; const float side_right = buf[in + 7] * m; - if constexpr (downmix == audio_channels::downmix_to_stereo) + if constexpr (downmix == audio_downmix::downmix_to_stereo) { // Don't mix in the lfe as per dolby specification and based on documentation const float mid = center * 0.5; out_buffer[out + 0] = left * minus_3db + mid + side_left * 0.5 + rear_left * 0.5; out_buffer[out + 1] = right * minus_3db + mid + side_right * 0.5 + rear_right * 0.5; } - else if constexpr (downmix == audio_channels::downmix_to_5_1) + else if constexpr (downmix == audio_downmix::downmix_to_5_1) { out_buffer[out + 0] = left; out_buffer[out + 1] = right; @@ -1016,14 +1016,14 @@ void cell_audio_thread::mix(float *out_buffer, s32 offset) const float side_left = buf[in + 6] * m; const float side_right = buf[in + 7] * m; - if constexpr (downmix == audio_channels::downmix_to_stereo) + if constexpr (downmix == audio_downmix::downmix_to_stereo) { // Don't mix in the lfe as per dolby specification and based on documentation const float mid = center * 0.5; out_buffer[out + 0] += left * minus_3db + mid + side_left * 0.5 + rear_left * 0.5; out_buffer[out + 1] += right * minus_3db + mid + side_right * 0.5 + rear_right * 0.5; } - else if constexpr (downmix == audio_channels::downmix_to_5_1) + else if constexpr (downmix == audio_downmix::downmix_to_5_1) { out_buffer[out + 0] += left; out_buffer[out + 1] += right; diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index e7c412e6ea..f5d126ed4c 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -196,7 +196,7 @@ struct cell_audio_config bool convert_to_u16 = false; u32 start_threshold = 0; u32 sampling_period_multiplier = 0; - audio_channels channels = audio_channels::downmix_to_stereo; + audio_downmix downmix = audio_downmix::downmix_to_stereo; audio_renderer renderer = audio_renderer::null; } raw; @@ -358,7 +358,7 @@ private: void reset_ports(s32 offset = 0); void advance(u64 timestamp, bool reset = true); std::tuple count_port_buffer_tags(); - template + template void mix(float *out_buffer, s32 offset = 0); void finish_port_volume_stepping(); diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index 8fe08f762e..fe07b56da7 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -217,7 +217,7 @@ struct cfg_root : cfg::node cfg::_bool dump_to_file{ this, "Dump to file" }; cfg::_bool convert_to_u16{ this, "Convert to 16 bit", false, true }; - cfg::_enum audio_channel_downmix{ this, "Audio Channels", audio_channels::downmix_to_stereo, true }; + cfg::_enum audio_channel_downmix{ this, "Audio Channels", audio_downmix::downmix_to_stereo, true }; cfg::_int<1, 128> start_threshold{ this, "Start Threshold", 1, true }; // TODO: used only by ALSA, should probably be removed once ALSA is upgraded cfg::_int<0, 200> volume{ this, "Master Volume", 100, true }; cfg::_bool enable_buffering{ this, "Enable Buffering", true, true }; diff --git a/rpcs3/Emu/system_config_types.cpp b/rpcs3/Emu/system_config_types.cpp index a735aff16c..a22055aefb 100644 --- a/rpcs3/Emu/system_config_types.cpp +++ b/rpcs3/Emu/system_config_types.cpp @@ -406,16 +406,16 @@ void fmt_class_string::format(std::string& out, u64 arg) } template <> -void fmt_class_string::format(std::string& out, u64 arg) +void fmt_class_string::format(std::string& out, u64 arg) { - format_enum(out, arg, [](audio_channels value) + format_enum(out, arg, [](audio_downmix value) { switch (value) { - case audio_channels::use_application_settings: return "Use application settings"; - case audio_channels::downmix_to_stereo: return "Downmix to Stereo"; - case audio_channels::downmix_to_5_1: return "Downmix to 5.1"; - case audio_channels::surround_7_1: return "Surround 7.1"; + case audio_downmix::no_downmix: return "No downmix"; + case audio_downmix::downmix_to_stereo: return "Downmix to Stereo"; + case audio_downmix::downmix_to_5_1: return "Downmix to 5.1"; + case audio_downmix::use_application_settings: return "Use application settings"; } return unknown; diff --git a/rpcs3/Emu/system_config_types.h b/rpcs3/Emu/system_config_types.h index af7ee47d0c..4dfcc07c50 100644 --- a/rpcs3/Emu/system_config_types.h +++ b/rpcs3/Emu/system_config_types.h @@ -75,12 +75,12 @@ enum class audio_renderer #endif }; -enum class audio_channels +enum class audio_downmix { - use_application_settings, + no_downmix, // Surround 7.1 downmix_to_stereo, downmix_to_5_1, - surround_7_1 + use_application_settings }; enum class camera_handler diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index b3d477b25c..7168813810 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -692,12 +692,12 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_ } break; case emu_settings_type::AudioChannels: - switch (static_cast(index)) + switch (static_cast(index)) { - case audio_channels::use_application_settings: return tr("Use application settings", "Audio channels"); - case audio_channels::downmix_to_stereo: return tr("Downmix to Stereo", "Audio channels"); - case audio_channels::downmix_to_5_1: return tr("Downmix to 5.1", "Audio channels"); - case audio_channels::surround_7_1: return tr("Surround 7.1", "Audio channels"); + case audio_downmix::no_downmix: return tr("Surround 7.1", "Audio downmix"); + case audio_downmix::downmix_to_stereo: return tr("Downmix to Stereo", "Audio downmix"); + case audio_downmix::downmix_to_5_1: return tr("Downmix to 5.1", "Audio downmix"); + case audio_downmix::use_application_settings: return tr("Use application settings", "Audio downmix"); } break; default: diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index cfc0fad8e3..6a8bddb6e7 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -727,10 +727,10 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std #endif connect(ui->audioOutBox, QOverload::of(&QComboBox::currentIndexChanged), enable_buffering); - m_emu_settings->EnhanceComboBox(ui->combo_audio_channels, emu_settings_type::AudioChannels); - SubscribeTooltip(ui->gb_audio_channels, tooltips.settings.audio_channels); - // TODO: enable this setting once cellAudioOutConfigure can change channels on the fly - ui->combo_audio_channels->removeItem(static_cast(audio_channels::use_application_settings)); + m_emu_settings->EnhanceComboBox(ui->combo_audio_downmix, emu_settings_type::AudioChannels); + SubscribeTooltip(ui->gb_audio_downmix, tooltips.settings.downmix); + // TODO: enable this setting once cellAudioOutConfigure can change downmix on the fly + ui->combo_audio_downmix->removeItem(static_cast(audio_downmix::use_application_settings)); // Microphone Comboboxes m_mics_combo[0] = ui->microphone1Box; diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 241c15f76b..f4d986116e 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -834,13 +834,13 @@ - + Audio Channels - + diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index 050aa171af..8941905f2d 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -45,7 +45,7 @@ public: const QString audio_out_linux = tr("OpenAL uses a cross-platform approach and supports audio buffering, so it is the recommended option.\nPulseAudio uses the native Linux sound system, and is the next best alternative. If neither are available, ALSA can be used instead."); const QString audio_dump = tr("Saves all audio as a raw wave file. If unsure, leave this unchecked."); const QString convert = tr("Uses 16-bit audio samples instead of default 32-bit floating point.\nUse with buggy audio drivers if you have no sound or completely broken sound."); - const QString audio_channels = tr("Uses chosen audio output instead of default 7.1 surround sound.\nUse downmix to stereo with stereo audio devices. Use 5.1 or higher only if you are using a surround sound audio system."); + const QString downmix = tr("Uses chosen audio output instead of default 7.1 surround sound.\nUse downmix to stereo with stereo audio devices. Use 5.1 or higher only if you are using a surround sound audio system."); const QString master_volume = tr("Controls the overall volume of the emulation.\nValues above 100% might reduce the audio quality."); const QString enable_buffering = tr("Enables audio buffering, which reduces crackle/stutter but increases audio latency (requires XAudio2 or OpenAL)."); const QString audio_buffer_duration = tr("Target buffer duration in milliseconds.\nHigher values make the buffering algorithm's job easier, but may introduce noticeable audio latency.");