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

[NON-MODULAR] Volume mixer #181

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions code/__HELPERS/announcements.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
if(islist(players))
for(var/mob/target in players)
to_chat(target, finalized_announcement)
if(play_sound && target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
if(play_sound && target.client?.prefs.read_preference(/datum/preference/numeric/sound_announcements)) //DOPPLER EDIT CHANGE - Original: if(play_sound && target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
SEND_SOUND(target, sound(sound_override))
else
to_chat(world, finalized_announcement)
Expand All @@ -59,7 +59,7 @@
return

for(var/mob/player in GLOB.player_list)
if(player.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
if(player.client?.prefs.read_preference(/datum/preference/numeric/sound_announcements)) //DOPPLER EDIT CHANGE - Original: if(player.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
SEND_SOUND(player, sound(sound_override))

/**
Expand Down
5 changes: 3 additions & 2 deletions code/__HELPERS/priority_announce.dm
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,16 @@
var/sound_to_play = !isnull(sound_override) ? sound_override : 'sound/announcer/notice/notice2.ogg'

for(var/mob/target in players)
var/volume_modifier = (target.client?.prefs.read_preference(/datum/preference/numeric/sound_announcements)) //DOPPLER EDIT ADDITION
if(isnewplayer(target) || !target.can_hear())
continue

to_chat(target, announcement)
if(!should_play_sound)
continue

if(target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
SEND_SOUND(target, sound(sound_to_play))
if(target.client?.prefs.read_preference(/datum/preference/numeric/sound_announcements)) //DOPPLER EDIT CHANGE - Original: if(target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
SEND_SOUND(target, sound(sound_to_play, volume = volume_modifier)) //DOPPLER EDIT CHANGE - Original: SEND_SOUND(target, sound(sound_to_play))

#undef MAJOR_ANNOUNCEMENT_TITLE
#undef MAJOR_ANNOUNCEMENT_TEXT
Expand Down
12 changes: 9 additions & 3 deletions code/controllers/subsystem/ambience.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ SUBSYSTEM_DEF(ambience)
///Attempts to play an ambient sound to a mob, returning the cooldown in deciseconds
/area/proc/play_ambience(mob/M, sound/override_sound, volume = 27)
var/sound/new_sound = override_sound || pick(ambientsounds)
new_sound = sound(new_sound, repeat = 0, wait = 0, volume = volume, channel = CHANNEL_AMBIENCE)
/* BEGIN DOPPLER EDIT - VOLUME MIXER
new_sound = sound(new_sound, repeat = 0, wait = 0, volume = volume, channel = CHANNEL_AMBIENCE)
changes old function to instead grab volume from player preferences */
var/volume_modifier = (M.client?.prefs.read_preference(/datum/preference/numeric/sound_ambience_volume))/100
new_sound = sound(new_sound, repeat = 0, wait = 0, volume = volume*volume_modifier, channel = CHANNEL_AMBIENCE)
// END DOPPLER EDIT
SEND_SOUND(M, new_sound)

return rand(min_ambience_cooldown, max_ambience_cooldown)
Expand Down Expand Up @@ -113,9 +118,10 @@ SUBSYSTEM_DEF(ambience)

var/area/my_area = get_area(src)
var/sound_to_use = my_area.ambient_buzz
var/volume_modifier = client.prefs.read_preference(/datum/preference/numeric/sound_ship_ambience_volume)

if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)))
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/numeric/sound_ship_ambience_volume))) //DOPPLER EDIT CHANGE - Original: if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)))
SEND_SOUND(src, sound(null, repeat = 0, volume = volume_modifier, wait = 0, channel = CHANNEL_BUZZ)) //DOPPLER EDIT CHANGE - Original: SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return

Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ SUBSYSTEM_DEF(vote)
new_voter.player_details.player_actions += voting_action
generated_actions += voting_action

if(current_vote.vote_sound && (new_voter.prefs.read_preference(/datum/preference/toggle/sound_announcements)))
if(current_vote.vote_sound && (new_voter.prefs.read_preference(/datum/preference/numeric/sound_announcements))) //DOPPLER EDIT CHANGE - Original: if(current_vote.vote_sound && (new_voter.prefs.read_preference(/datum/preference/toggle/sound_announcements)))
SEND_SOUND(new_voter, sound(current_vote.vote_sound))

return TRUE
Expand Down
14 changes: 10 additions & 4 deletions code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,13 @@

if(isliving(talking_movable))
var/mob/living/talking_living = talking_movable
/*BEGIN DOPPLER EDIT - VOLUME MIXER
if(radio_noise && !HAS_TRAIT(talking_living, TRAIT_DEAF) && talking_living.client?.prefs.read_preference(/datum/preference/toggle/radio_noise))
SEND_SOUND(talking_living, 'sound/items/radio/radio_talk.ogg')
SEND_SOUND(talking_living, 'sound/items/radio/radio_talk.ogg') */
var/volume_modifier = (talking_living.client?.prefs.read_preference(/datum/preference/numeric/sound_radio_noise))
if(radio_noise && !HAS_TRAIT(talking_living, TRAIT_DEAF) && volume_modifier)
SEND_SOUND(talking_living, sound('sound/items/radio/radio_talk.ogg', volume = volume_modifier))
///END DOPPLER EDIT

// All radios make an attempt to use the subspace system first
signal.send_to_receivers()
Expand Down Expand Up @@ -429,16 +434,17 @@
return

var/mob/living/holder = loc
if(!radio_noise || HAS_TRAIT(holder, TRAIT_DEAF) || !holder.client?.prefs.read_preference(/datum/preference/toggle/radio_noise))
var/volume_modifier = (holder.client?.prefs.read_preference(/datum/preference/numeric/sound_radio_noise))
if(!radio_noise || HAS_TRAIT(holder, TRAIT_DEAF) || !holder.client?.prefs.read_preference(/datum/preference/numeric/sound_radio_noise)) //DOPPLER EDIT CHANGE - Original: if(!radio_noise || HAS_TRAIT(holder, TRAIT_DEAF) || !holder.client?.prefs.read_preference(/datum/preference/toggle/radio_noise))
return

var/list/spans = data["spans"]
if(COOLDOWN_FINISHED(src, audio_cooldown))
COOLDOWN_START(src, audio_cooldown, 0.5 SECONDS)
SEND_SOUND(holder, 'sound/items/radio/radio_receive.ogg')
SEND_SOUND(holder, sound('sound/items/radio/radio_receive.ogg', volume = volume_modifier)) //DOPPLER EDIT CHANGE - Original: SEND_SOUND(holder, 'sound/items/radio/radio_receive.ogg')
if((SPAN_COMMAND in spans) && COOLDOWN_FINISHED(src, important_audio_cooldown))
COOLDOWN_START(src, important_audio_cooldown, 0.5 SECONDS)
SEND_SOUND(holder, 'sound/items/radio/radio_important.ogg')
SEND_SOUND(holder, sound('sound/items/radio/radio_important.ogg', volume = volume_modifier)) //DOPPLER EDIT CHANGE - Original: SEND_SOUND(holder, 'sound/items/radio/radio_important.ogg')

/obj/item/radio/ui_state(mob/user)
return GLOB.inventory_state
Expand Down
7 changes: 6 additions & 1 deletion code/game/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,13 @@
set waitfor = FALSE
UNTIL(SSticker.login_music) //wait for SSticker init to set the login music

/* BEGIN DOPPLER EDIT - VOLUME MIXER
if(prefs && (prefs.read_preference(/datum/preference/toggle/sound_lobby)) && !CONFIG_GET(flag/disallow_title_music))
SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = vol, channel = CHANNEL_LOBBYMUSIC)) // MAD JAMS
SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = vol, channel = CHANNEL_LOBBYMUSIC)) */
var/volume_modifier = prefs.read_preference(/datum/preference/numeric/sound_lobby)
if((prefs && volume_modifier) && !CONFIG_GET(flag/disallow_title_music))
SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = volume_modifier, channel = CHANNEL_LOBBYMUSIC)) // MAD JAMS
///END DOPPLER EDIT

/proc/get_rand_frequency()
return rand(32000, 55000) //Frequency stuff only works with 45kbps oggs.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them.
to_chat(src, span_warning("Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you."))

update_ambience_pref(prefs.read_preference(/datum/preference/toggle/sound_ambience))
update_ambience_pref(prefs.read_preference(/datum/preference/numeric/sound_ambience_volume)) //DOPPLER EDIT CHANGE - Original: update_ambience_pref(prefs.read_preference(/datum/preference/toggle/sound_ambience))
check_ip_intel()

//This is down here because of the browse() calls in tooltip/New()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
/// This migration transfers the player's existing preferences into the new toggles

/datum/preferences/proc/migrate_legacy_sound_toggles(savefile/savefile)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ambience], toggles & 1<<2)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_announcements], toggles & 1<<11)
// BEGIN DOPPLER EDIT - VOLUME MIXER
// write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ambience], toggles & 1<<2)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_ambience_volume], toggles & 1<<2)
// write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_announcements], toggles & 1<<11)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_announcements], toggles & 1<<11)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_combatmode], toggles & 1<<22)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_endofround], toggles & 1<<20)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_instruments], toggles & 1<<7)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_lobby], toggles & 1<<3)
// write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_lobby], toggles & 1<<3)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_lobby], toggles & 1<<3)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_midi], toggles & 1<<1)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ship_ambience], toggles & 1<<8)
// write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ship_ambience], toggles & 1<<8)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_ship_ambience_volume], toggles & 1<<8)
// END DOPPLER EDIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** Pull request: #86932 Sound mixer part 1
*
* Multiplies boolean sound prefs by 100
*
* Changed ambience tick pref to numeric slider
* Changed ship ambience tick pref to numeric slider
* Changed lobby music tick pref to numeric slider
* Changed Radio noise tick pref to numeric slider
*/

/datum/preferences/proc/migrate_boolean_sound_prefs_to_default_volume()
var/ambience_pref = savefile.get_entry("sound_ambience_volume")
var/announcement_pref = savefile.get_entry("sound_announcements")
var/ship_ambience_pref = savefile.get_entry("sound_ship_ambience_volume")
var/lobby_music_pref = savefile.get_entry("sound_lobby")
var/radio_noise_pref = savefile.get_entry("sound_radio_noise")
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_ambience_volume], ambience_pref*100)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_announcements], announcement_pref*100)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_ship_ambience_volume], ship_ambience_pref*100)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_lobby], lobby_music_pref*100)
write_preference(GLOB.preference_entries[/datum/preference/numeric/sound_radio_noise], radio_noise_pref*100)
return
59 changes: 49 additions & 10 deletions code/modules/client/preferences/sounds.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/// Controls hearing ambience
/datum/preference/toggle/sound_ambience
/datum/preference/numeric/sound_ambience_volume //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_ambience
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_ambience"
savefile_key = "sound_ambience_volume" //DOPPLER EDIT CHANGE - Original: savefile_key = "sound_ambience"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 200

//BEGIN DOPPLER ADDITION - VOLUME MIXER
// default value is max/2 because 100 1x modifier, while 200 is 2x
/datum/preference/numeric/sound_ambience_volume/create_default_value()
return maximum/2
//END DOPPLER ADD

/datum/preference/toggle/sound_ambience/apply_to_client(client/client, value)
/datum/preference/numeric/sound_ambience_volume/apply_to_client(client/client, value) //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_ambience/apply_to_client(client/client, value)
client.update_ambience_pref(value)

/datum/preference/toggle/sound_breathing
Expand All @@ -13,10 +21,17 @@
savefile_identifier = PREFERENCE_PLAYER

/// Controls hearing announcement sounds
/datum/preference/toggle/sound_announcements
/datum/preference/numeric/sound_announcements //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_announcements
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_announcements"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 200

//BEGIN DOPPLER ADDITION - VOLUME MIXER
/datum/preference/numeric/sound_announcements/create_default_value()
return maximum/2
///END DOPPLER ADD

/// Controls hearing the combat mode toggle sound
/datum/preference/toggle/sound_combatmode
Expand Down Expand Up @@ -85,12 +100,20 @@
client.mob.stop_sound_channel(CHANNEL_JUKEBOX)

/// Controls hearing lobby music
/datum/preference/toggle/sound_lobby
/datum/preference/numeric/sound_lobby //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_lobby
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_lobby"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 200

/datum/preference/toggle/sound_lobby/apply_to_client_updated(client/client, value)
//BEGIN DOPPLER ADDITION - VOLUME MIXER
// default value is max/2 because 100 1x modifier, while 200 is 2x
/datum/preference/numeric/sound_lobby/create_default_value()
return maximum/2
//END DOPPLER ADD

/datum/preference/numeric/sound_lobby/apply_to_client_updated(client/client, value) //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_lobby/apply_to_client_updated(client/client, value)
if (value && isnewplayer(client.mob))
client.playtitlemusic()
else
Expand All @@ -103,12 +126,20 @@
savefile_identifier = PREFERENCE_PLAYER

/// Controls hearing ship ambience
/datum/preference/toggle/sound_ship_ambience
/datum/preference/numeric/sound_ship_ambience_volume //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_ship_ambience
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_ship_ambience"
savefile_key = "sound_ship_ambience_volume" //DOPPLER EDIT CHANGE - Original: savefile_key = "sound_ship_ambience"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 200

//BEGIN DOPPLER ADDITION - VOLUME MIXER
// default value is max/2 because 100 1x modifier, while 200 is 2x
/datum/preference/numeric/sound_ship_ambience_volume/create_default_value()
return maximum/2
//END DOPPLER ADD

/datum/preference/toggle/sound_ship_ambience/apply_to_client_updated(client/client, value)
/datum/preference/numeric/sound_ship_ambience_volume/apply_to_client_updated(client/client, value) //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/sound_ship_ambience/apply_to_client_updated(client/client, value)
client.mob.refresh_looping_ambience()

/// Controls hearing elevator music
Expand All @@ -118,7 +149,15 @@
savefile_identifier = PREFERENCE_PLAYER

/// Controls hearing radio noise
/datum/preference/toggle/radio_noise
/datum/preference/numeric/sound_radio_noise //DOPPLER EDIT CHANGE - Original: /datum/preference/toggle/radio_noise
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_radio_noise"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 200

//BEGIN DOPPLER ADDITION - VOLUME MIXER
/// default value is max/2 because 100 1x modifier, while 200 is 2x
/datum/preference/numeric/sound_radio_noise/create_default_value()
return maximum/2
//END DOPPLER ADD
6 changes: 5 additions & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// You do not need to raise this if you are adding new values that have sane defaults.
// Only raise this value when changing the meaning/format/name/layout of an existing value
// where you would want the updater procs below to run
#define SAVEFILE_VERSION_MAX 45
#define SAVEFILE_VERSION_MAX 46 //DOPPLER EDIT CHANGE - Original: #define SAVEFILE_VERSION_MAX 45

/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
Expand Down Expand Up @@ -110,6 +110,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
new_typepath = /obj/item/clothing/accessory/pride,
data_to_migrate = list(INFO_RESKIN = save_data?["pride_pin"]),
)
//BEGIN DOPPLER ADDITION - VOLUME MIXER
if (current_version < 46)
migrate_boolean_sound_prefs_to_default_volume()
//END DOPPLER ADD

/// checks through keybindings for outdated unbound keys and updates them
/datum/preferences/proc/check_keybindings()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/ai/ai_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
if(!only_listener)
// Play voice for all mobs in the z level
for(var/mob/player_mob as anything in GLOB.player_list)
if(!player_mob.can_hear() || !(safe_read_pref(player_mob.client, /datum/preference/toggle/sound_announcements)))
if(!player_mob.can_hear() || !(safe_read_pref(player_mob.client, /datum/preference/numeric/sound_announcements))) //DOPPLER EDIT CHANGE - Original: if(!player_mob.can_hear() || !(safe_read_pref(player_mob.client, /datum/preference/toggle/sound_announcements)))
continue

var/turf/player_turf = get_turf(player_mob)
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3884,6 +3884,7 @@
#include "code\modules\client\preferences\migrations\convert_to_json_savefile.dm"
#include "code\modules\client\preferences\migrations\legacy_sound_toggles_migration.dm"
#include "code\modules\client\preferences\migrations\quirk_loadout_migration.dm"
#include "code\modules\client\preferences\migrations\sound_checkboxes_migration.dm"
#include "code\modules\client\preferences\migrations\tgui_prefs_migration.dm"
#include "code\modules\client\preferences\migrations\tts_blip_migration.dm"
#include "code\modules\client\preferences\species_features\basic.dm"
Expand Down
Loading
Loading