diff --git a/SQL/migrate/V054__preference_asfx_instrument.sql b/SQL/migrate/V054__preference_asfx_instrument.sql
new file mode 100644
index 00000000000..e2884fa0a90
--- /dev/null
+++ b/SQL/migrate/V054__preference_asfx_instrument.sql
@@ -0,0 +1,5 @@
+--
+-- Set default 'On' for 'asfx_instruments'
+--
+
+UPDATE `ss13_player_preferences` SET `asfx_togs` = `asfx_togs` | 128;
\ No newline at end of file
diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm
index c2c22aa1805..aa7e2361a49 100644
--- a/code/__defines/misc.dm
+++ b/code/__defines/misc.dm
@@ -74,8 +74,9 @@
#define ASFX_DROPSOUND 16
#define ASFX_ARCADE 32
#define ASFX_RADIO 64
+#define ASFX_INSTRUMENT 128
-#define ASFX_DEFAULT (ASFX_AMBIENCE|ASFX_FOOTSTEPS|ASFX_VOTE|ASFX_VOX|ASFX_DROPSOUND|ASFX_ARCADE|ASFX_RADIO)
+#define ASFX_DEFAULT (ASFX_AMBIENCE|ASFX_FOOTSTEPS|ASFX_VOTE|ASFX_VOX|ASFX_DROPSOUND|ASFX_ARCADE|ASFX_RADIO|ASFX_INSTRUMENT)
// For secHUDs and medHUDs and variants. The number is the location of the image on the list hud_list of humans.
#define HEALTH_HUD 1 // A simple line reading the pulse.
diff --git a/code/game/objects/items/devices/violin.dm b/code/game/objects/items/devices/violin.dm
index 7521253ae30..1f49f304060 100644
--- a/code/game/objects/items/devices/violin.dm
+++ b/code/game/objects/items/devices/violin.dm
@@ -189,7 +189,9 @@
if("Cn9") soundfile = 'sound/violin/Cn9.mid'
else return
- hearers(15, get_turf(src)) << sound(soundfile)
+ var/turf/source = get_turf(src)
+ for(var/mob/M in hearers(15, source))
+ M.playsound_simple(source, file(soundfile), 100, falloff = 5, required_asfx_toggles = ASFX_INSTRUMENT)
/obj/item/device/violin/proc/playsong()
do
diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm
index 95783bd5410..5a6da39e0f4 100644
--- a/code/game/objects/structures/musician.dm
+++ b/code/game/objects/structures/musician.dm
@@ -209,7 +209,7 @@
//hearers(15, src) << sound(soundfile)
var/turf/source = get_turf(src)
for(var/mob/M in hearers(15, source))
- M.playsound_simple(source, file(soundfile), 100, falloff = 5)
+ M.playsound_simple(source, file(soundfile), 100, falloff = 5, required_asfx_toggles = ASFX_INSTRUMENT)
/obj/structure/device/piano/proc/playsong()
do
diff --git a/code/game/sound.dm b/code/game/sound.dm
index 25683d2cea5..7b04dce8ec0 100644
--- a/code/game/sound.dm
+++ b/code/game/sound.dm
@@ -363,11 +363,14 @@ var/list/bodyfall_machine_sound = list(
else
return ..()
-/mob/proc/playsound_to(turf/source_turf, sound/original_sound, use_random_freq, modify_environment = TRUE, use_pressure = TRUE)
+/mob/proc/playsound_to(turf/source_turf, sound/original_sound, use_random_freq, modify_environment = TRUE, use_pressure = TRUE, required_preferences = 0, required_asfx_toggles = 0)
var/sound/S = copy_sound(original_sound)
var/pressure_factor = 1.0
+ if(!sound_can_play(required_preferences, required_asfx_toggles))
+ return 0
+
if (use_random_freq)
S.frequency = get_rand_frequency()
@@ -409,10 +412,10 @@ var/list/bodyfall_machine_sound = list(
return S.volume
-/mob/proc/playsound_simple(source, soundin, volume, use_random_freq = FALSE, frequency = 0, falloff = 0, use_pressure = TRUE)
+/mob/proc/playsound_simple(source, soundin, volume, use_random_freq = FALSE, frequency = 0, falloff = 0, use_pressure = TRUE, required_preferences = 0, required_asfx_toggles = 0)
var/sound/S = playsound_get_sound(soundin, volume, falloff, frequency)
- playsound_to(source ? get_turf(source) : null, S, use_random_freq, use_pressure = use_pressure)
+ playsound_to(source ? get_turf(source) : null, S, use_random_freq, use_pressure = use_pressure, required_preferences = required_preferences, required_asfx_toggles = required_asfx_toggles)
/client/proc/playtitlemusic()
if(!SSticker.login_music) return
diff --git a/code/modules/client/preferences_ambience.dm b/code/modules/client/preferences_ambience.dm
index 7dd4b4e2453..514524a8f76 100644
--- a/code/modules/client/preferences_ambience.dm
+++ b/code/modules/client/preferences_ambience.dm
@@ -5,13 +5,14 @@
/client/proc/toggle_vox_voice,
/client/proc/Toggle_dropsounds,
/client/proc/Toggle_arcadesounds,
- /client/proc/Toggle_radiosounds
+ /client/proc/Toggle_radiosounds,
+ /client/proc/Toggle_instrumentsounds
)
/client/verb/asf_toggle()
set name = "Open ASFX Tab"
set category = "Preferences"
- set desc = "Open the ambiance sound effects toggle tab"
+ set desc = "Open the ambience sound effects toggle tab"
verbs ^= asfx_togs
return
@@ -99,4 +100,16 @@
if(prefs.asfx_togs & ASFX_RADIO)
to_chat(src, "You will now hear radio sounds.")
else
- to_chat(src, "You will no longer hear radio sounds.")
\ No newline at end of file
+ to_chat(src, "You will no longer hear radio sounds.")
+
+/client/proc/Toggle_instrumentsounds()
+ set name = "Toggle Instrument SFX"
+ set category = "SoundFx Prefs"
+ set desc = "Toggles hearing noises made by instruments."
+
+ prefs.asfx_togs ^= ASFX_INSTRUMENT
+ prefs.save_preferences()
+ if(prefs.asfx_togs & ASFX_INSTRUMENT)
+ to_chat(src, "You will now hear instrument sounds.")
+ else
+ to_chat(src, "You will no longer hear instrument sounds.")
\ No newline at end of file
diff --git a/html/changelogs/instrument_sound_toggle.yml b/html/changelogs/instrument_sound_toggle.yml
new file mode 100644
index 00000000000..1415e175102
--- /dev/null
+++ b/html/changelogs/instrument_sound_toggle.yml
@@ -0,0 +1,6 @@
+author: mikomyazaki
+
+delete-after: True
+
+changes:
+ - rscadd: "There is now a preference to toggle instrument sound effects under the ASFX menu."
\ No newline at end of file