mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
## About The Pull Request This pull request implements sound tokens, based on the implementation by Kapu at https://github.com/DaedalusDock/daedalusdock/pull/1379 I've taken that implementation and extended it to looping_sounds, allowing us to have spatial audio that updates much more nicely when players walk closer. This system also lets players that walk into range after the sound has started playing to also hear the sound, before if you missed the sound, you would never hear it. This is particularly noticeable with long sounds (Which is lame!) **VIDEOS**: griddle: https://streamable.com/v7ayqm engineering / SM: https://streamable.com/5lr1oj The system essentially sends the sound to every client, and changes the volume based on distance to the sound. There are some performance concerns here, so we will need to testmerge this and see how impactful it is. It is in a subsystem though, so there is some limit to the amount of cpu it will use. Do keep this in mind when watching the videos; it will probably not be AS responsive as in there. I've also changed how intense our fall-off is, making sounds lose their volume slower. Before taking one step away from a 50 volume sound would make it 18 volume, this is way too big of a drop and it became particularly jarring with the changes in this PR. Some sounds might be too long range now, but I think we should just reduce the max range of those sounds as we were basically playing them at <5 volume after 10 tiles, at which point we should maybe just reduce the range a bit since at those volumes theyre really not audible. **OLD FALLOFF;** note the MASSIVE drop from 1 tile to 2 tiles <img width="1416" height="897" alt="image" src="https://github.com/user-attachments/assets/805b270e-6aa5-4e84-868e-39585966f0a4" /> **NEW FALLOFF:** <img width="1418" height="905" alt="image" src="https://github.com/user-attachments/assets/eabbd592-ae9c-4690-8945-fbd0b4f6614f" /> Also tweaked a few looping sounds (deep-fryer in particular got some clean-up, as its mid-length was way too short for the sounds and it had a double-definition) ## Why It's Good For The Game This system allows us to have a richer audio experience, I really don't like how choppy our looping sounds are, especially in some areas where you hear them a lot (kitchen and engineering) ## Changelog 🆑 CabinetOnFire, Kapu sound: Changed our falloff to be less intense, as it was punching volume down way too fast. refactor: Implements a system for spatial audio to improve our looping sounds /🆑 --------- Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
58 lines
2.2 KiB
Plaintext
58 lines
2.2 KiB
Plaintext
PROCESSING_SUBSYSTEM_DEF(instruments)
|
|
name = "Instruments"
|
|
wait = 0.5
|
|
ss_flags = SS_KEEP_TIMING
|
|
priority = FIRE_PRIORITY_INSTRUMENTS
|
|
/// List of all instrument data, associative id = datum
|
|
var/static/list/datum/instrument/instrument_data = list()
|
|
/// List of all song datums.
|
|
var/static/list/datum/song/songs = list()
|
|
/// Max lines in songs
|
|
var/static/musician_maxlines = 600
|
|
/// Max characters per line in songs
|
|
var/static/musician_maxlinechars = 300
|
|
/// Deciseconds between hearchecks. Too high and instruments seem to lag when people are moving around in terms of who can hear it. Too low and the server lags from this.
|
|
var/static/musician_hearcheck_mindelay = 5
|
|
/// Maximum instrument channels total instruments are allowed to use. This is so you don't have instruments deadlocking all sound channels.
|
|
var/static/max_instrument_channels = MAX_INSTRUMENT_CHANNELS
|
|
/// Current number of channels allocated for instruments
|
|
var/static/current_instrument_channels = 0
|
|
/// Single cached list for synthesizer instrument ids, so you don't have to have a new list with every synthesizer.
|
|
var/static/list/synthesizer_instrument_ids
|
|
var/static/list/note_sustain_modes = list(
|
|
SUSTAIN_LINEAR,
|
|
SUSTAIN_EXPONENTIAL,
|
|
)
|
|
|
|
/datum/controller/subsystem/processing/instruments/Initialize()
|
|
initialize_instrument_data()
|
|
synthesizer_instrument_ids = get_allowed_instrument_ids()
|
|
return SS_INIT_SUCCESS
|
|
|
|
/datum/controller/subsystem/processing/instruments/proc/on_song_new(datum/song/S)
|
|
songs += S
|
|
|
|
/datum/controller/subsystem/processing/instruments/proc/on_song_del(datum/song/S)
|
|
songs -= S
|
|
|
|
/datum/controller/subsystem/processing/instruments/proc/initialize_instrument_data()
|
|
for(var/path in valid_subtypesof(/datum/instrument))
|
|
var/datum/instrument/I = path
|
|
I = new path
|
|
I.Initialize()
|
|
if(!I.id)
|
|
qdel(I)
|
|
continue
|
|
instrument_data[I.id] = I
|
|
CHECK_TICK
|
|
|
|
/datum/controller/subsystem/processing/instruments/proc/get_instrument(id_or_path)
|
|
return instrument_data["[id_or_path]"]
|
|
|
|
/datum/controller/subsystem/processing/instruments/proc/reserve_instrument_channel(datum/instrument/I)
|
|
if(current_instrument_channels > max_instrument_channels)
|
|
return
|
|
. = SSsounds.reserve_sound_channel_for_datum(I)
|
|
if(!isnull(.))
|
|
current_instrument_channels++
|