Skip to content

Commit

Permalink
Merge branch 'tts-update' of ssh://github.com/larentoun/tgstation int…
Browse files Browse the repository at this point in the history
…o tts-update
  • Loading branch information
Furrior committed Apr 10, 2024
2 parents 9d1a6d5 + 8ba1054 commit bbfde60
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
10 changes: 5 additions & 5 deletions modular_bandastation/_singletons/code/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

/// Get a singleton instance according to path P. Creates it if necessary. Null if abstract or not a singleton.
#define GET_SINGLETON(P)\
(ispath(P, /singleton) ? (GLOB.Singletons.resolved_instances[P] ? GLOB.Singletons.instances[P] : GLOB.Singletons.GetInstance(P)) : null)
(ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_instances[P] ? GLOB.Singletons.instances[P] : GLOB.Singletons.GetInstance(P)) : null)

/// Get a (path = instance) map of valid singletons according to typesof(P).
#define GET_SINGLETON_TYPE_MAP(P)\
(ispath(P, /singleton) ? (GLOB.Singletons.resolved_type_maps[P] ? GLOB.Singletons.type_maps[P] : GLOB.Singletons.GetTypeMap(P)) : list())
(ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_type_maps[P] ? GLOB.Singletons.type_maps[P] : GLOB.Singletons.GetTypeMap(P)) : list())

/// Get a (path = instance) map of valid singletons according to subtypesof(P).
#define GET_SINGLETON_SUBTYPE_MAP(P)\
(ispath(P, /singleton) ? (GLOB.Singletons.resolved_subtype_maps[P] ? GLOB.Singletons.subtype_maps[P] : GLOB.Singletons.GetSubtypeMap(P)) : list())
(ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_subtype_maps[P] ? GLOB.Singletons.subtype_maps[P] : GLOB.Singletons.GetSubtypeMap(P)) : list())

/// Get a list of valid singletons according to typesof(path).
#define GET_SINGLETON_TYPE_LIST(P)\
(ispath(P, /singleton) ? (GLOB.Singletons.resolved_type_lists[P] ? GLOB.Singletons.type_lists[P] : GLOB.Singletons.GetTypeList(P)) : list())
(ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_type_lists[P] ? GLOB.Singletons.type_lists[P] : GLOB.Singletons.GetTypeList(P)) : list())

/// Get a list of valid singletons according to subtypesof(path).
#define GET_SINGLETON_SUBTYPE_LIST(P)\
(ispath(P, /singleton) ? (GLOB.Singletons.resolved_subtype_lists[P] ? GLOB.Singletons.subtype_lists[P] : GLOB.Singletons.GetSubtypeList(P)) : list())
(ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_subtype_lists[P] ? GLOB.Singletons.subtype_lists[P] : GLOB.Singletons.GetSubtypeList(P)) : list())
22 changes: 11 additions & 11 deletions modular_bandastation/_singletons/code/repository.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,36 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new)
* Get a singleton instance according to path. Creates it if necessary. Null if abstract or not a singleton.
* Prefer the GET_SINGLETON macro to minimize proc calls.
*/
/repository/singletons/proc/GetInstance(singleton/path)
if(!ispath(path, /singleton))
/repository/singletons/proc/GetInstance(datum/singleton/path)
if(!ispath(path, /datum/singleton))
return
if(resolved_instances[path])
return instances[path]
resolved_instances[path] = TRUE
if(path == initial(path.abstract_type))
return
var/singleton/result = new path
var/datum/singleton/result = new path
instances[path] = result
result.Initialize()
return result


/// Get a (path = instance) map of valid singletons according to paths.
/repository/singletons/proc/GetMap(list/singleton/paths)
/repository/singletons/proc/GetMap(list/datum/singleton/paths)
var/list/result = list()
for(var/path in paths)
var/singleton/instance = GetInstance(path)
var/datum/singleton/instance = GetInstance(path)
if (!instance)
continue
result[path] = instance
return result


/// Get a list of valid singletons according to paths.
/repository/singletons/proc/GetList(list/singleton/paths)
/repository/singletons/proc/GetList(list/datum/singleton/paths)
var/list/result = list()
for(var/path in paths)
var/singleton/instance = GetInstance(path)
var/datum/singleton/instance = GetInstance(path)
if(!instance)
continue
result += instance
Expand All @@ -99,7 +99,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new)
* Get a (path = instance) map of valid singletons according to typesof(path).
* Prefer the GET_SINGLETON_TYPE_MAP macro to minimize proc calls.
*/
/repository/singletons/proc/GetTypeMap(singleton/path)
/repository/singletons/proc/GetTypeMap(datum/singleton/path)
if(resolved_type_maps[path])
return type_maps[path] || list()
resolved_type_maps[path] = TRUE
Expand All @@ -112,7 +112,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new)
* Get a (path = instance) map of valid singletons according to subtypesof(path).
* Prefer the GET_SINGLETON_TYPE_MAP macro to minimize proc calls.
*/
/repository/singletons/proc/GetSubtypeMap(singleton/path)
/repository/singletons/proc/GetSubtypeMap(datum/singleton/path)
if(resolved_subtype_maps[path])
return subtype_maps[path] || list()
resolved_subtype_maps[path] = TRUE
Expand All @@ -125,7 +125,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new)
* Get a list of valid singletons according to typesof(path).
* Prefer the GET_SINGLETON_TYPE_LIST macro to minimize proc calls.
*/
/repository/singletons/proc/GetTypeList(singleton/path)
/repository/singletons/proc/GetTypeList(datum/singleton/path)
if(resolved_type_lists[path])
return type_lists[path] || list()
resolved_type_lists[path] = TRUE
Expand All @@ -138,7 +138,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new)
* Get a list of valid singletons according to subtypesof(path).
* Prefer the GET_SINGLETON_SUBTYPE_LIST macro to minimize proc calls.
*/
/repository/singletons/proc/GetSubtypeList(singleton/path)
/repository/singletons/proc/GetSubtypeList(datum/singleton/path)
if(resolved_subtype_lists[path])
return subtype_lists[path] || list()
resolved_subtype_lists[path] = TRUE
Expand Down
8 changes: 4 additions & 4 deletions modular_bandastation/_singletons/code/singletons.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/singleton
var/abstract_type = /singleton
/datum/singleton
var/abstract_type = /datum/singleton

/singleton/proc/Initialize()
/datum/singleton/proc/Initialize()
SHOULD_CALL_PARENT(TRUE)
SHOULD_NOT_SLEEP(TRUE)

/singleton/Destroy()
/datum/singleton/Destroy()
SHOULD_CALL_PARENT(FALSE)
. = QDEL_HINT_LETMELIVE
CRASH("Prevented attempt to delete a singleton instance: [src]")
4 changes: 2 additions & 2 deletions modular_bandastation/tts/code/hear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
. = ..()
if(!.)
return
speaker.cast_tts(src, raw_message, effect = radio_freq ? /singleton/sound_effect/radio : null)
speaker.cast_tts(src, raw_message, effect = radio_freq ? /datum/singleton/sound_effect/radio : null)

/mob/dead/observer/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods, message_range)
. = ..()
if(!.)
return
speaker.cast_tts(src, raw_message, effect = radio_freq ? /singleton/sound_effect/radio : null)
speaker.cast_tts(src, raw_message, effect = radio_freq ? /datum/singleton/sound_effect/radio : null)
14 changes: 7 additions & 7 deletions modular_bandastation/tts/code/shell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SHELLEO_ERR ".err"
#define SHELLEO_OUT ".out"

/proc/apply_sound_effect(singleton/sound_effect/effect, filename_input, filename_output)
/proc/apply_sound_effect(datum/singleton/sound_effect/effect, filename_input, filename_output)
if(!effect)
CRASH("Invalid sound effect chosen.")

Expand All @@ -28,27 +28,27 @@
return FALSE
return TRUE

/singleton/sound_effect
/datum/singleton/sound_effect
var/suffix
var/ffmpeg_arguments

/singleton/sound_effect/radio
/datum/singleton/sound_effect/radio
suffix = "_radio"
ffmpeg_arguments = "highpass=f=1000, lowpass=f=3000, acrusher=1:1:50:0:log"

/singleton/sound_effect/robot
/datum/singleton/sound_effect/robot
suffix = "_robot"
ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, volume=volume=1.5"

/singleton/sound_effect/radio_robot
/datum/singleton/sound_effect/radio_robot
suffix = "_radio_robot"
ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, volume=volume=1.5, highpass=f=1000, lowpass=f=3000, acrusher=1:1:50:0:log"

/singleton/sound_effect/megaphone
/datum/singleton/sound_effect/megaphone
suffix = "_megaphone"
ffmpeg_arguments = "highpass=f=500, lowpass=f=4000, volume=volume=10, acrusher=1:1:45:0:log"

/singleton/sound_effect/megaphone_robot
/datum/singleton/sound_effect/megaphone_robot
suffix = "_megaphone_robot"
ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, highpass=f=500, lowpass=f=4000, volume=volume=10, acrusher=1:1:45:0:log"

Expand Down
12 changes: 6 additions & 6 deletions modular_bandastation/tts/code/tts_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@
switch(.)
if(null)
if(TTS_TRAIT_ROBOTIZE in traits)
return /singleton/sound_effect/robot
if(/singleton/sound_effect/radio)
return /datum/singleton/sound_effect/robot
if(/datum/singleton/sound_effect/radio)
if(TTS_TRAIT_ROBOTIZE in traits)
return /singleton/sound_effect/radio_robot
if(/singleton/sound_effect/megaphone)
return /datum/singleton/sound_effect/radio_robot
if(/datum/singleton/sound_effect/megaphone)
if(TTS_TRAIT_ROBOTIZE in traits)
return /singleton/sound_effect/megaphone_robot
return /datum/singleton/sound_effect/megaphone_robot
return .

/datum/component/tts_component/proc/cast_tts(atom/speaker, mob/listener, message, atom/location, is_local = TRUE, effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX, postSFX)
Expand All @@ -129,7 +129,7 @@
speaker = parent
if(!location)
location = parent
if(effect == /singleton/sound_effect/radio)
if(effect == /datum/singleton/sound_effect/radio)
if(listener == speaker && !issilicon(parent)) // don't hear both radio and whisper from yourself
return

Expand Down
8 changes: 4 additions & 4 deletions modular_bandastation/tts/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ SUBSYSTEM_DEF(tts220)
LAZYADD(tts_requests_queue, list(list(text, seed, proc_callback)))
return TRUE

/datum/controller/subsystem/tts220/proc/get_tts(atom/speaker, mob/listener, message, datum/tts_seed/tts_seed, is_local = TRUE, singleton/sound_effect/effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX = null, postSFX = null)
/datum/controller/subsystem/tts220/proc/get_tts(atom/speaker, mob/listener, message, datum/tts_seed/tts_seed, is_local = TRUE, datum/singleton/sound_effect/effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX = null, postSFX = null)
if(!is_enabled)
return
if(!message)
Expand Down Expand Up @@ -269,7 +269,7 @@ SUBSYSTEM_DEF(tts220)
var/hash = md5(lowertext(text))

var/filename = "data/tts_cache/[tts_seed.name]/[hash]"
var/singleton/sound_effect/effect_singleton = GET_SINGLETON(effect)
var/datum/singleton/sound_effect/effect_singleton = GET_SINGLETON(effect)

if(fexists("[filename].ogg"))
tts_reused++
Expand Down Expand Up @@ -338,7 +338,7 @@ SUBSYSTEM_DEF(tts220)
request.cb = output_tts_cb
LAZYADD(tts_effects_queue[processed_filename], request)

/datum/controller/subsystem/tts220/proc/play_tts(atom/speaker, mob/listener, pure_filename, is_local = TRUE, singleton/sound_effect/effect = null, preSFX = null, postSFX = null)
/datum/controller/subsystem/tts220/proc/play_tts(atom/speaker, mob/listener, pure_filename, is_local = TRUE, datum/singleton/sound_effect/effect = null, preSFX = null, postSFX = null)
if(isnull(listener) || !listener.client)
return

Expand Down Expand Up @@ -480,7 +480,7 @@ SUBSYSTEM_DEF(tts220)
/datum/sound_effect_request
var/original_filename
var/output_filename
var/singleton/sound_effect/effect
var/datum/singleton/sound_effect/effect
var/datum/callback/cb

#undef TTS_REPLACEMENTS_FILE_PATH
Expand Down

0 comments on commit bbfde60

Please sign in to comment.