Merge pull request #20652 from hrydgard/game-preview-music-volume

Separate out GamePreviewVolume from UIVolume
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-07-20 10:24:17 +02:00
commit 5a572879a4
50 files changed
+73 -16

No files matched your search

+6
View File
@@ -769,6 +769,11 @@ static int DefaultAchievementVolume() {
return MultiplierToVolume100((float)g_Config.iLegacyAchievementVolume / 10.0f);
}
static int DefaultGamePreviewVolume() {
// This was previously controlled by the UI volume, so transfer the default value over.
return g_Config.iUIVolume;
}
static const ConfigSetting soundSettings[] = {
ConfigSetting("Enable", &g_Config.bEnableSound, true, CfgFlag::PER_GAME),
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, CfgFlag::DEFAULT),
@@ -786,6 +791,7 @@ static const ConfigSetting soundSettings[] = {
ConfigSetting("AltSpeedRelativeVolume", &g_Config.iAltSpeedVolume, VOLUMEHI_FULL, CfgFlag::PER_GAME),
ConfigSetting("AchievementVolume", &g_Config.iAchievementVolume, &DefaultAchievementVolume, CfgFlag::PER_GAME),
ConfigSetting("UIVolume", &g_Config.iUIVolume, 75, CfgFlag::DEFAULT),
ConfigSetting("GamePreviewVolume", &g_Config.iGamePreviewVolume, &DefaultGamePreviewVolume, CfgFlag::DEFAULT),
ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", CfgFlag::DEFAULT),
ConfigSetting("AutoAudioDevice", &g_Config.bAutoAudioDevice, true, CfgFlag::DEFAULT),
+1
View File
@@ -298,6 +298,7 @@ public:
int iGameVolume;
int iReverbVolume;
int iUIVolume;
int iGamePreviewVolume; // Volume for the game preview sound in the game grid.
int iAchievementVolume;
int iAltSpeedVolume;
+14 -14
View File
@@ -273,19 +273,19 @@ private:
BackgroundAudio g_BackgroundAudio;
BackgroundAudio::BackgroundAudio() {
buffer = new int[BUFSIZE]();
buffer_ = new int[BUFSIZE]();
sndLoadPending_.store(false);
}
BackgroundAudio::~BackgroundAudio() {
delete at3Reader_;
delete[] buffer;
delete[] buffer_;
}
void BackgroundAudio::Clear(bool hard) {
if (!hard) {
fadingOut_ = true;
volume_ = 1.0f;
volumeFader_ = 1.0f;
return;
}
if (at3Reader_) {
@@ -313,7 +313,7 @@ void BackgroundAudio::SetGame(const Path &path) {
sndLoadPending_ = true;
fadingOut_ = false;
}
volume_ = 1.0f;
volumeFader_ = 1.0f;
bgGamePath_ = path;
}
@@ -335,30 +335,30 @@ bool BackgroundAudio::Play() {
sz = std::min(BUFSIZE / 2, sz);
if (at3Reader_) {
if (at3Reader_->Read(buffer, sz)) {
if (at3Reader_->Read(buffer_, sz)) {
if (fadingOut_) {
float vol = volume_;
float vol = volumeFader_;
// TODO: This isn't optimized. But hardly matters...
for (int i = 0; i < sz * 2; i += 2) {
const float v = vol;
buffer[i] = (int)((float)buffer[i] * v);
buffer[i + 1] = (int)((float)buffer[i + 1] * v);
buffer_[i] = (int)((float)buffer_[i] * v);
buffer_[i + 1] = (int)((float)buffer_[i + 1] * v);
vol += delta_;
}
volume_ = vol;
volumeFader_ = vol;
}
}
} else {
for (int i = 0; i < sz * 2; i += 2) {
buffer[i] = 0;
buffer[i + 1] = 0;
buffer_[i] = 0;
buffer_[i + 1] = 0;
}
}
float multiplier = Volume100ToMultiplier(g_Config.iUIVolume);
System_AudioPushSamples(buffer, sz, multiplier);
float multiplier = Volume100ToMultiplier(g_Config.iGamePreviewVolume);
System_AudioPushSamples(buffer_, sz, multiplier);
if (at3Reader_ && fadingOut_ && volume_ <= 0.0f) {
if (at3Reader_ && fadingOut_ && volumeFader_ <= 0.0f) {
Clear(true);
fadingOut_ = false;
gameLastChanged_ = 0;
+2 -2
View File
@@ -79,9 +79,9 @@ private:
AT3PlusReader *at3Reader_ = nullptr;
double gameLastChanged_ = 0.0;
double lastPlaybackTime_ = 0.0;
int *buffer = nullptr;
int *buffer_ = nullptr;
bool fadingOut_ = true;
float volume_ = 0.0f;
float volumeFader_ = 0.0f;
float delta_ = -0.0001f;
SoundEffectMixer sfxMixer_;
};
+5
View File
@@ -677,6 +677,11 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) {
return UI::EVENT_DONE;
});
PopupSliderChoice *gamePreviewVolume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGamePreviewVolume, VOLUME_OFF, VOLUMEHI_FULL, NO_DEFAULT_INT, a->T("Game preview volume"), screenManager()));
gamePreviewVolume->SetFormat("%d%%");
gamePreviewVolume->SetEnabledPtr(&g_Config.bEnableSound);
gamePreviewVolume->SetZeroLabel(a->T("Mute"));
bool sdlAudio = false;
#if defined(SDL)
+1
View File
@@ -79,6 +79,7 @@ Buffer size = Buffer size
Device = جهاز
Disabled = غير مفعل
Enable Sound = ‎تفعيل الصوت
Game preview volume = Game preview volume
Game volume = ‎الصوت العام
Microphone = Microphone
Microphone Device = جهاز المايكروفون
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Səs Açıq
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Прылада
Disabled = Адкл.
Enable Sound = Уключыць гук
Game preview volume = Game preview volume
Game volume = Гучнасць гульні
Microphone = Мікрафон
Microphone Device = Прылада мікрафона
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Устройство
Disabled = Disabled
Enable Sound = Включи звук
Game preview volume = Game preview volume
Game volume = Обем на звука на играта
Microphone = Микрофон
Microphone Device = Микрофонно устройство
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Dispositiu
Disabled = Disabled
Enable Sound = Activar el so
Game preview volume = Game preview volume
Game volume = Volum global
Microphone = Micròfon
Microphone Device = Dispositiu de micròfon
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Povolit zvuk
Game preview volume = Game preview volume
Game volume = Celková hlasitost
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Aktiver lyd
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -70,6 +70,7 @@ Auto = Autom.
Device = Gerät
Disabled = Deaktiviert
Enable Sound = Ton aktivieren
Game preview volume = Game preview volume
Game volume = Spiellautstärke
Microphone = Mikrofon
Microphone Device = Mikrofon-Gerät
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Padenni suarana
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -95,6 +95,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Enable sound
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Tamaño del búfer
Device = Dispositivo
Disabled = Desactivado
Enable Sound = Activar sonido
Game preview volume = Game preview volume
Game volume = Volumen global
Microphone = Micrófono
Microphone Device = Dispositivo de entrada
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Dispositivo
Disabled = Deshabilitado
Enable Sound = Habilitar sonido
Game preview volume = Game preview volume
Game volume = Volumen global
Microphone = Micrófono
Microphone Device = Dispositivo de entrada de sonido (Micrófono)
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = سیستم
Disabled = فعال کردن
Enable Sound = ‎فعال کردن صدا
Game preview volume = Game preview volume
Game volume = ‎بلندی صدا
Microphone = میکروفن
Microphone Device = میکروفن دستگاه
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Laite
Disabled = Poistettu käytöstä
Enable Sound = Ota äänet käyttöön
Game preview volume = Game preview volume
Game volume = Yleinen äänenvoimakkuus
Microphone = Mikrofoni
Microphone Device = Mikrofonin laite
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Périphérique de sortie
Disabled = Disabled
Enable Sound = Activer le son
Game preview volume = Game preview volume
Game volume = Volume global
Microphone = Micro
Microphone Device = Micro
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Activar son
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Συσκευή
Disabled = Disabled
Enable Sound = Ενεργοποίηση Ήχου
Game preview volume = Game preview volume
Game volume = Γενική ένταση
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = אפשר שמע
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = עמש רשפא
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Uređaj
Disabled = Disabled
Enable Sound = Uključi zvuk
Game preview volume = Game preview volume
Game volume = Opća glasnoća
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Eszköz
Disabled = Kikapcsolva
Enable Sound = Hang bekapcsolása
Game preview volume = Game preview volume
Game volume = Globális hangerő
Microphone = Mikrofon
Microphone Device = Mikrofon eszköz
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Perangkat
Disabled = Nonaktif
Enable Sound = Aktifkan suara
Game preview volume = Game preview volume
Game volume = Volume global
Microphone = Mikrofon
Microphone Device = Mikrofon perangkat
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Dispositivo
Disabled = Disabilitato
Enable Sound = Attiva il Sonoro
Game preview volume = Game preview volume
Game volume = Volume Globale
Microphone = Microfono
Microphone Device = Periferica Microfono
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = デバイス
Disabled = 無効
Enable Sound = オーディオを有効にする
Game preview volume = Game preview volume
Game volume = グローバルボリューム
Microphone = マイクの設定
Microphone Device = マイク入力機器の選択
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Ngatifke Suoro
Game preview volume = Game preview volume
Game volume = Tingkat Volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = 버퍼 크기
Device = 장치
Disabled = 비활성화
Enable Sound = 사운드 활성화
Game preview volume = Game preview volume
Game volume = 글로벌 볼륨
Microphone = 마이크
Microphone Device = 마이크 장치
+1
View File
@@ -84,6 +84,7 @@ Buffer size = Buffer size
Device = ئامێر
Disabled = لەکار خراوە
Enable Sound = بەکارکردنی دەنگ
Game preview volume = Game preview volume
Game volume = دەنگی گشتی
Microphone = مایکرۆفۆن
Microphone Device = ئامێری مایکرۆفۆن
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = ເປີດໃຊ້ງານສຽງ
Game preview volume = Game preview volume
Game volume = ລະດັບສຽງຫຼັກ
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Įjungti garsą
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Upayakan suara
Game preview volume = Game preview volume
Game volume = Volume keseluruhan
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Geluid inschakelen
Game preview volume = Game preview volume
Game volume = Globaal volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Lyd
Game preview volume = Game preview volume
Game volume = Game volume
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Urządzenie
Disabled = Wył.
Enable Sound = Włącz dźwięk
Game preview volume = Game preview volume
Game volume = Głośność globalna
Microphone = Mikrofon
Microphone Device = Mikrofon
+1
View File
@@ -96,6 +96,7 @@ Device = Dispositivo
Disabled = Desativado
DSound (compatible) = DirectSound (compatível)
Enable Sound = Ativar áudio
Game preview volume = Game preview volume
Game volume = Volume do jogo
Microphone = Microfone
Microphone Device = Dispositivo Microfone
+1
View File
@@ -95,6 +95,7 @@ Buffer size = Buffer size
Device = Dispositivo
Disabled = Desativado
Enable Sound = Ativar Áudio
Game preview volume = Game preview volume
Game volume = Volume Global
Microphone = Microfone
Microphone Device = Dispositivo de Microfone
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Activează Sunet
Game preview volume = Game preview volume
Game volume = Volum global
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Размер буфера
Device = Устройство
Disabled = Откл.
Enable Sound = Включить звук
Game preview volume = Game preview volume
Game volume = Громкость игры
Microphone = Микрофон
Microphone Device = Устройство микрофона
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Enhet
Disabled = Inaktiverad
Enable Sound = Ljud på
Game preview volume = Game preview volume
Game volume = Spelvolym
Microphone = Mikrofon
Microphone Device = Mikrofonenhet
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Kagamitan
Disabled = Huwag paganahin
Enable Sound = Paganahin ang tunog
Game preview volume = Game preview volume
Game volume = Pangkalahatang tunog
Microphone = Mikropono
Microphone Device = Device ng Mikropono
+1
View File
@@ -71,6 +71,7 @@ Buffer size = ขนาดบัฟเฟอร์
Device = อุปกรณ์
Disabled = ปิดการใช้งาน
Enable Sound = เปิดการใช้งานเสียง
Game preview volume = Game preview volume
Game volume = ระดับเสียงเกม
Microphone = ไมโครโฟน
Microphone Device = อุปกรณ์ไมโครโฟน
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Arabellek Boyutu
Device = Cihaz
Disabled = Devre Dışı
Enable Sound = Sesi Etkinleştir
Game preview volume = Game preview volume
Game volume = Oyun Sesi
Microphone = Mikrofon
Microphone Device = Mikrofon Cihazı
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Пристрій
Disabled = Вимкнуто
Enable Sound = Ввімкнути звук
Game preview volume = Game preview volume
Game volume = Глобальна гучність
Microphone = Мікрофон
Microphone Device = Мікрофонний пристрій
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = Device
Disabled = Disabled
Enable Sound = Mở âm thanh
Game preview volume = Game preview volume
Game volume = Âm lượng
Microphone = Microphone
Microphone Device = Microphone device
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = 设备
Disabled = 禁用
Enable Sound = 开启声音
Game preview volume = Game preview volume
Game volume = 全局音量
Microphone = 麦克风
Microphone Device = 麦克风设备
+1
View File
@@ -71,6 +71,7 @@ Buffer size = Buffer size
Device = 裝置
Disabled = 已停用
Enable Sound = 啟用音效
Game preview volume = Game preview volume
Game volume = 全域音量
Microphone = 麥克風
Microphone Device = 麥克風裝置