From e13a77dd91220c1520f6d926cec6b057e79a5c1b Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 12 Jun 2023 02:20:58 -0700 Subject: [PATCH] Allow object sounds to fade out to 0 --- lang/Czech.ini | 1 + lang/Dutch.ini | 1 + lang/English.ini | 1 + lang/French.ini | 1 + lang/German.ini | 1 + lang/Italian.ini | 1 + lang/Portuguese.ini | 1 + lang/Russian.ini | 1 + lang/Spanish.ini | 1 + src/audio/external.c | 10 +++++++--- src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + src/pc/djui/djui_panel_sound.c | 1 + 13 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lang/Czech.ini b/lang/Czech.ini index da1af56c..42945e84 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Hlavní hlasitost" MUSIC_VOLUME = "Hlasitost písničky" SFX_VOLUME = "Hlasitost zvuků" ENV_VOLUME = "Hlasitost prostředí" +FADEOUT = "Fadeout Distant Sounds" [LANGUAGE] LANGUAGE = "JAZYK" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index b3dfb9ce..e0b5f404 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -336,6 +336,7 @@ MASTER_VOLUME = "Meester Geluid" MUSIC_VOLUME = "Muziek Geluid" SFX_VOLUME = "Sfx Geluid" ENV_VOLUME = "Env Geluid" +FADEOUT = "Fade-out verre geluiden" [LANGUAGE] LANGUAGE = "TAAL" diff --git a/lang/English.ini b/lang/English.ini index 27efbd09..95725c63 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Master Volume" MUSIC_VOLUME = "Music Volume" SFX_VOLUME = "Sfx Volume" ENV_VOLUME = "Env Volume" +FADEOUT = "Fadeout Distant Sounds" [LANGUAGE] LANGUAGE = "LANGUAGE" diff --git a/lang/French.ini b/lang/French.ini index 22b7ef90..53587a18 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Volume principal" MUSIC_VOLUME = "Volume de la musique" SFX_VOLUME = "Volume des effets sonores" ENV_VOLUME = "Volume de l'environnement" +FADEOUT = "Fondu des sons distants" [LANGUAGE] LANGUAGE = "LANGUE" diff --git a/lang/German.ini b/lang/German.ini index f3c0efe6..9f247486 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Hauptlautstärke" MUSIC_VOLUME = "Musik Lautstärke" SFX_VOLUME = "Geräusch Lautstärke" ENV_VOLUME = "Env Lautstärke" +FADEOUT = "Entfernte Geräusche Ausblenden" [LANGUAGE] LANGUAGE = "SPRACHE" diff --git a/lang/Italian.ini b/lang/Italian.ini index e5443135..3ceec56e 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -335,6 +335,7 @@ MASTER_VOLUME = "Principale" MUSIC_VOLUME = "Musica" SFX_VOLUME = "Effetti sonori" ENV_VOLUME = "Ambiente" +FADEOUT = "Suoni lontani in dissolvenza" [LANGUAGE] LANGUAGE = "LINGUA" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 09d12f52..ea35e5ef 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Volume Geral" MUSIC_VOLUME = "Volume da Música" SFX_VOLUME = "Volume dos Efeitos" ENV_VOLUME = "Volume Ambiente" +FADEOUT = "Desaparecimento do som com a distância" [LANGUAGE] LANGUAGE = "IDIOMA" diff --git a/lang/Russian.ini b/lang/Russian.ini index 9c784775..8048ca5b 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -337,6 +337,7 @@ MASTER_VOLUME = "Общая громкость" MUSIC_VOLUME = "Громкость музыки" SFX_VOLUME = "Громкость звуков" ENV_VOLUME = "Объёмное звучание" +FADEOUT = "Затухание далеких звуков" [LANGUAGE] LANGUAGE = "LANGUAGE" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 1b92e449..92815b44 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -338,6 +338,7 @@ MASTER_VOLUME = "Volumen General" MUSIC_VOLUME = "Volumen de Música" SFX_VOLUME = "Volumen de Efectos de Sonido" ENV_VOLUME = "Volumen de Entorno" +FADEOUT = "Desvanecimiento de sonidos distantes" [LANGUAGE] LANGUAGE = "IDIOMA" diff --git a/src/audio/external.c b/src/audio/external.c index 4cbe523b..65596696 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1264,11 +1264,15 @@ f32 get_sound_pan(f32 x, f32 z) { * Called from threads: thread4_sound, thread5_game_loop (EU only) */ static f32 get_sound_volume(u8 bank, u8 soundIndex, f32 volumeRange) { + if (configFadeoutDistantSounds) { + volumeRange = 1; + } + if (bank >= SOUND_BANK_COUNT || soundIndex >= SOUND_INDEX_COUNT) { return 0; } - f32 maxSoundDistance; - f32 intensity; + f32 maxSoundDistance = AUDIO_MAX_DISTANCE; + f32 intensity = 0; #ifndef VERSION_JP - s32 div = bank < 3 ? 2 : 3; + f32 div = (bank < 3) ? 2.0f : 3.0f; #endif if (!(sSoundBanks[bank][soundIndex].soundBits & SOUND_NO_VOLUME_LOSS)) { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index e88df77c..ee664dc3 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -158,6 +158,7 @@ bool configForce4By3 = false; char configCoopNetIp[MAX_CONFIG_STRING] = DEFAULT_COOPNET_IP; unsigned int configCoopNetPort = DEFAULT_COOPNET_PORT; char configPassword[MAX_CONFIG_STRING] = ""; +bool configFadeoutDistantSounds = true; static const struct ConfigOption options[] = { {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen}, @@ -268,6 +269,7 @@ static const struct ConfigOption options[] = { {.name = "coopnet_ip", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configCoopNetIp, .maxStringLength = MAX_CONFIG_STRING}, {.name = "coopnet_port", .type = CONFIG_TYPE_UINT , .uintValue = &configCoopNetPort}, {.name = "coopnet_password", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configPassword, .maxStringLength = MAX_CONFIG_STRING}, + {.name = "fade_distant_sounds", .type = CONFIG_TYPE_BOOL , .boolValue = &configFadeoutDistantSounds}, }; // FunctionConfigOption functions diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 15b40ae6..e927046c 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -115,6 +115,7 @@ extern bool configForce4By3; extern char configCoopNetIp[]; extern unsigned int configCoopNetPort; extern char configPassword[]; +extern bool configFadeoutDistantSounds; void configfile_load(void); void configfile_save(const char *filename); diff --git a/src/pc/djui/djui_panel_sound.c b/src/pc/djui/djui_panel_sound.c index 3098c1d7..7fd16d20 100644 --- a/src/pc/djui/djui_panel_sound.c +++ b/src/pc/djui/djui_panel_sound.c @@ -13,6 +13,7 @@ void djui_panel_sound_create(struct DjuiBase* caller) { djui_slider_create(body, DLANG(SOUND, MUSIC_VOLUME), &configMusicVolume, 0, 127, NULL); djui_slider_create(body, DLANG(SOUND, SFX_VOLUME), &configSfxVolume, 0, 127, NULL); djui_slider_create(body, DLANG(SOUND, ENV_VOLUME), &configEnvVolume, 0, 127, NULL); + djui_checkbox_create(body, DLANG(SOUND, FADEOUT), &configFadeoutDistantSounds, NULL); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); }