From 4ffa797fb183ff20aca9d86611080fd76b0490ff Mon Sep 17 00:00:00 2001 From: Gaxeer <44334376+Gaxeer@users.noreply.github.com> Date: Sun, 19 Jan 2025 19:14:55 +0200 Subject: [PATCH 1/2] add announcement tts effect, sync pre sfx, tts and post sfx (#1011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Что этот PR делает Добавляет новый эффект для ТТСа оповещений Синхронизирует preSXF и postSFX с ТТСом ## Почему это хорошо для игры Атмосферный эффект оповещение и отсутствия наложения звука оповещений ## Changelog :cl: add: Добавляет новый эффект для ТТСа оповещений fix: preSXF и postSFX теперь синхронизируются с ТТСом /:cl: ## Summary by Sourcery Add a new announcement TTS effect and synchronize pre, TTS, and post sound effects. New Features: - Added a new "announcement" sound effect for TTS, which includes reverb, filtering, and dynamic range compression, creating a more atmospheric and immersive experience for announcements. Tests: - Ensured the new announcement sound effect is used for priority announcements. --------- Co-authored-by: dj-34 --- code/__HELPERS/priority_announce.dm | 3 +-- modular_bandastation/tts/code/shell.dm | 26 ++++++++++++++++++- modular_bandastation/tts/code/tts_hear.dm | 2 +- .../tts/code/tts_subsystem.dm | 15 ++++++++--- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/code/__HELPERS/priority_announce.dm b/code/__HELPERS/priority_announce.dm index 84148d603edae..f8d85e3545224 100644 --- a/code/__HELPERS/priority_announce.dm +++ b/code/__HELPERS/priority_announce.dm @@ -207,7 +207,6 @@ // SEND_SOUND(target, sound(sound_to_play)) // Bandastion Removal /// SS220 TTS START var/datum/tts_seed/announcement_tts_seed = tts_override?.tts_seed - var/list/tts_effects = tts_override?.get_effects() if(isnull(announcement_tts_seed)) var/mob/living/silicon/ai/active_ai = DEFAULTPICK(active_ais(TRUE, null), null) announcement_tts_seed = active_ai ? active_ai.get_tts_seed() : /datum/tts_seed/silero/glados @@ -220,7 +219,7 @@ announcement, \ announcement_tts_seed, \ FALSE, \ - tts_effects, \ + list(/datum/singleton/sound_effect/announcement), \ null, \ sound_to_play \ ) diff --git a/modular_bandastation/tts/code/shell.dm b/modular_bandastation/tts/code/shell.dm index d97c99f5707fb..c1b7e3ebe617c 100644 --- a/modular_bandastation/tts/code/shell.dm +++ b/modular_bandastation/tts/code/shell.dm @@ -11,11 +11,19 @@ CRASH("Invalid sound effect chosen.") var/list/ffmpeg_arguments = list() + var/complex = FALSE for(var/datum/singleton/sound_effect/effect as anything in effects) + if(effect.complex) + ffmpeg_arguments = list(effect.ffmpeg_arguments) + complex = TRUE + break + ffmpeg_arguments |= effect.ffmpeg_arguments var/taskset = CONFIG_GET(string/ffmpeg_cpuaffinity) ? "taskset -ac [CONFIG_GET(string/ffmpeg_cpuaffinity)]" : "" - var/command = {"[taskset] ffmpeg -y -hide_banner -loglevel error -i [filename_input] -filter:a "[ffmpeg_arguments.Join(", ")]" [filename_output]"} + var/filter_part = complex ? ffmpeg_arguments.Join() : {"-filter:a "[ffmpeg_arguments.Join(", ")]""} + + var/command = {"[taskset] ffmpeg -y -hide_banner -loglevel error -i [filename_input] [filter_part] [filename_output]"} var/list/output = world.shelleo(command) var/errorlevel = output[SHELLEO_ERRORLEVEL] @@ -27,12 +35,18 @@ logger.Log(LOG_CATEGORY_DEBUG, "apply_sound_effects([effect_types], [filename_input], [filename_output]) STDOUT: [stdout]") logger.Log(LOG_CATEGORY_DEBUG, "apply_sound_effects([effect_types], [filename_input], [filename_output]) STDERR: [stderr]") return FALSE + return TRUE /datum/singleton/sound_effect + /// If set to TRUE, this effect will ignore all other filters. + var/complex = FALSE + /// Text suffix used for caching file with specific effects. var/suffix + /// Filter arguments passed to ffmpeg. var/ffmpeg_arguments + /datum/singleton/sound_effect/radio suffix = "_radio" ffmpeg_arguments = "highpass=f=1000, lowpass=f=3000, acrusher=1:1:50:0:log" @@ -45,6 +59,16 @@ suffix = "_megaphone" ffmpeg_arguments = "highpass=f=500, lowpass=f=4000, volume=volume=10, acrusher=1:1:45:0:log" +/datum/singleton/sound_effect/announcement + complex = TRUE + suffix = "_announcement" + ffmpeg_arguments = {"\ + -i ./tools/tts/tts-api/RoomImpulse.wav -filter_complex \ + "\[0:a\]apad=pad_dur=2\[dry\]; \ + \[0:a\]apad=pad_dur=2,afir=dry=10:wet=10\[wet\]; \ + \[dry\]\[wet\]amix=weights='1 0.1',acrusher=mix=0.1:mode=lin:aa=1:samples=250,highpass=f=200,lowpass=f=10000,alimiter=limit=-1dB:level=false:asc=true"\ + "} + #undef SHELLEO_ERRORLEVEL #undef SHELLEO_STDOUT #undef SHELLEO_STDERR diff --git a/modular_bandastation/tts/code/tts_hear.dm b/modular_bandastation/tts/code/tts_hear.dm index 4d0e3e60925d0..253aaf95d0607 100644 --- a/modular_bandastation/tts/code/tts_hear.dm +++ b/modular_bandastation/tts/code/tts_hear.dm @@ -19,7 +19,7 @@ var/dist = get_dist(speaker, src) - message_range if(dist > 0 && dist <= EAVESDROP_EXTRA_RANGE && !HAS_TRAIT(src, TRAIT_GOOD_HEARING) && !isobserver(src)) return - speaker.cast_tts(src, raw_message, is_local = (message_range != INFINITY), is_radio = !!radio_freq, effects = message_mods[MODE_TTS_FILTERS]) + speaker.cast_tts(src, raw_message, is_local = (message_range != INFINITY), is_radio = !!radio_freq, effects = LAZYACCESS(message_mods, MODE_TTS_FILTERS)) /mob/dead/observer/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods, message_range) . = ..() diff --git a/modular_bandastation/tts/code/tts_subsystem.dm b/modular_bandastation/tts/code/tts_subsystem.dm index 641a88eb51817..6809fca2bbeb0 100644 --- a/modular_bandastation/tts/code/tts_subsystem.dm +++ b/modular_bandastation/tts/code/tts_subsystem.dm @@ -234,7 +234,7 @@ SUBSYSTEM_DEF(tts220) datum/tts_seed/tts_seed, is_local = TRUE, list/effect_types, - traits = TTS_TRAIT_RATE_FASTER, + traits = TTS_TRAIT_RATE_MEDIUM, preSFX = null, postSFX = null ) @@ -262,9 +262,11 @@ SUBSYSTEM_DEF(tts220) var/dirty_text = message var/text = sanitize_tts_input(dirty_text) - if(!text || length_char(text) > MAX_MESSAGE_LEN) + if(!text) return + text = trim(text, MAX_MESSAGE_LEN) + if(traits & TTS_TRAIT_RATE_FASTER) text = provider.rate_faster(text) @@ -364,6 +366,10 @@ SUBSYSTEM_DEF(tts220) var/list/filename_suffixes = list() for(var/datum/singleton/sound_effect/effect as anything in effects) + if(effect.complex) + filename_suffixes = list(effect.suffix) + break + filename_suffixes |= effect.suffix sortTim(filename_suffixes, GLOBAL_PROC_REF(cmp_text_asc)) @@ -429,14 +435,15 @@ SUBSYSTEM_DEF(tts220) /datum/controller/subsystem/tts220/proc/play_sfx_if_exists(mob/listener, sfx, sound/output) if(sfx) - play_sfx(listener, sfx, output.volume, output.environment) + play_sfx(listener, sfx, output.volume, output.environment, output.channel) -/datum/controller/subsystem/tts220/proc/play_sfx(mob/listener, sfx, volume, environment) +/datum/controller/subsystem/tts220/proc/play_sfx(mob/listener, sfx, volume, environment, channel) var/sound/output = sound(sfx) output.status = SOUND_STREAM output.wait = TRUE output.volume = volume output.environment = environment + output.channel = channel SEND_SOUND(listener, output) /datum/controller/subsystem/tts220/proc/get_local_channel_by_owner(owner) From cee287c98b0d69b9f38445ce3fe32de97a3f20c8 Mon Sep 17 00:00:00 2001 From: "ss220app[bot]" <167440448+ss220app[bot]@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:15:16 +0000 Subject: [PATCH 2/2] Automatic changelog for PR #1011 [ci skip] --- html/changelogs/bandastation/AutoChangeLog-pr-1011.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 html/changelogs/bandastation/AutoChangeLog-pr-1011.yml diff --git a/html/changelogs/bandastation/AutoChangeLog-pr-1011.yml b/html/changelogs/bandastation/AutoChangeLog-pr-1011.yml new file mode 100644 index 0000000000000..96c6bfd761949 --- /dev/null +++ b/html/changelogs/bandastation/AutoChangeLog-pr-1011.yml @@ -0,0 +1,5 @@ +author: "Gaxeer" +delete-after: True +changes: + - rscadd: "Добавляет новый эффект для ТТСа оповещений" + - bugfix: "preSXF и postSFX теперь синхронизируются с ТТСом" \ No newline at end of file