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.
This commit is contained in:
Megamouse 2020-07-08 20:42:45 +02:00
parent e2fd4e46f7
commit 53b95fea19
10 changed files with 50 additions and 50 deletions

View File

@ -21,24 +21,24 @@ AudioBackend::AudioBackend()
m_sampling_rate = static_cast<u32>(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<int>(channels));
fmt::throw_exception("Unknown audio channel mode %s (%d)", downmix, static_cast<int>(downmix));
}
}

View File

@ -548,7 +548,7 @@ namespace audio
.convert_to_u16 = static_cast<bool>(g_cfg.audio.convert_to_u16),
.start_threshold = static_cast<u32>(g_cfg.audio.start_threshold),
.sampling_period_multiplier = static_cast<u32>(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<audio_channels::downmix_to_stereo>(buf);
mix<audio_downmix::downmix_to_stereo>(buf);
break;
case 6:
mix<audio_channels::downmix_to_5_1>(buf);
mix<audio_downmix::downmix_to_5_1>(buf);
break;
case 8:
mix<audio_channels::surround_7_1>(buf);
mix<audio_downmix::no_downmix>(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 <audio_channels downmix>
template <audio_downmix downmix>
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;

View File

@ -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<u32, u32, u32, u32> count_port_buffer_tags();
template <audio_channels downmix>
template <audio_downmix downmix>
void mix(float *out_buffer, s32 offset = 0);
void finish_port_volume_stepping();

View File

@ -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_channels> audio_channel_downmix{ this, "Audio Channels", audio_channels::downmix_to_stereo, true };
cfg::_enum<audio_downmix> 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 };

View File

@ -406,16 +406,16 @@ void fmt_class_string<shader_mode>::format(std::string& out, u64 arg)
}
template <>
void fmt_class_string<audio_channels>::format(std::string& out, u64 arg)
void fmt_class_string<audio_downmix>::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;

View File

@ -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

View File

@ -692,12 +692,12 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_
}
break;
case emu_settings_type::AudioChannels:
switch (static_cast<audio_channels>(index))
switch (static_cast<audio_downmix>(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:

View File

@ -727,10 +727,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
#endif
connect(ui->audioOutBox, QOverload<int>::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<int>(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<int>(audio_downmix::use_application_settings));
// Microphone Comboboxes
m_mics_combo[0] = ui->microphone1Box;

View File

@ -834,13 +834,13 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_audio_channels">
<widget class="QGroupBox" name="gb_audio_downmix">
<property name="title">
<string>Audio Channels</string>
</property>
<layout class="QVBoxLayout" name="gb_audio_channels_layout">
<item>
<widget class="QComboBox" name="combo_audio_channels"/>
<widget class="QComboBox" name="combo_audio_downmix"/>
</item>
</layout>
</widget>

View File

@ -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.");