Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tts for players is queued #149

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tts for players is queued
larentoun committed Apr 20, 2024
commit 661f56d7a44e540aaaf12cd38a2f50621efcbaee
5 changes: 4 additions & 1 deletion code/__DEFINES/sound.dm
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@
#define CHANNEL_TRAITOR 1016
#define CHANNEL_CHARGED_SPELL 1015
#define CHANNEL_ELEVATOR 1014
// BANDASTATION ADDITION START
#define CHANNEL_TTS_RADIO 1013
// BANDASTATION EDIT END

///Default range of a sound.
#define SOUND_RANGE 17
@@ -26,7 +29,7 @@
//THIS SHOULD ALWAYS BE THE LOWEST ONE!
//KEEP IT UPDATED

#define CHANNEL_HIGHEST_AVAILABLE 1015
#define CHANNEL_HIGHEST_AVAILABLE 1012 // BANDASTATION EDIT

#define MAX_INSTRUMENT_CHANNELS (128 * 6)

16 changes: 15 additions & 1 deletion modular_bandastation/tts/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ SUBSYSTEM_DEF(tts220)
/// Lazy list of request that need to performed to TTS provider API
VAR_PRIVATE/list/tts_requests_queue

/// List of currently existing binding of atom and sound channel: `atom` => `sound_channel`. SS220 TODO: free channel when atom is detroyed and may be on some other circumstances
/// List of currently existing binding of atom and sound channel: `atom` => `sound_channel`.
VAR_PRIVATE/list/tts_local_channels_by_owner = list()

/// Mapping of BYOND gender to TTS gender
@@ -365,6 +365,7 @@ SUBSYSTEM_DEF(tts220)
output.wait = TRUE
output.volume = volume
output.environment = SOUND_ENVIRONMENT_NONE
output.channel = CHANNEL_TTS_RADIO

if(output.volume <= 0)
return
@@ -377,6 +378,12 @@ SUBSYSTEM_DEF(tts220)

play_sfx_if_exists(listener, preSFX, output)

// Reserve channel only for players
if(ismob(speaker))
var/mob/speaking_mob = speaker
if(speaking_mob.client)
output.channel = get_local_channel_by_owner(speaker)
output.wait = TRUE
output = listener.playsound_local(turf_source, output, volume)

if(!output || output.volume <= 0)
@@ -396,6 +403,13 @@ SUBSYSTEM_DEF(tts220)
output.environment = environment
SEND_SOUND(listener, output)

/datum/controller/subsystem/tts220/proc/get_local_channel_by_owner(owner)
var/channel = tts_local_channels_by_owner[owner]
if(isnull(channel))
channel = SSsounds.reserve_sound_channel()
tts_local_channels_by_owner[owner] = channel
return channel

/datum/controller/subsystem/tts220/proc/cleanup_tts_file(filename)
fdel(filename)

Loading