Skip to content

Commit

Permalink
Merge branch 'master' into tts-only-for-announcement-body
Browse files Browse the repository at this point in the history
  • Loading branch information
AyIong committed Jan 19, 2025
2 parents a3ed82c + cee287c commit 88d0186
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
3 changes: 1 addition & 2 deletions code/__HELPERS/priority_announce.dm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,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
Expand All @@ -223,7 +222,7 @@
tts_message, \
announcement_tts_seed, \
FALSE, \
tts_effects, \
list(/datum/singleton/sound_effect/announcement), \
null, \
sound_to_play \
)
Expand Down
5 changes: 5 additions & 0 deletions html/changelogs/bandastation/AutoChangeLog-pr-1011.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
author: "Gaxeer"
delete-after: True
changes:
- rscadd: "Добавляет новый эффект для ТТСа оповещений"
- bugfix: "preSXF и postSFX теперь синхронизируются с ТТСом"
26 changes: 25 additions & 1 deletion modular_bandastation/tts/code/shell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modular_bandastation/tts/code/tts_hear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
15 changes: 11 additions & 4 deletions modular_bandastation/tts/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 88d0186

Please sign in to comment.