Files
2025-02-05 06:19:18 +00:00

28 lines
40 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/song - /tg/ Station 13</title></head><body><header><a href="index.html">/tg/ Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a><a href="datum/song.html#var">Var Details</a> - <a href="datum/song.html#proc">Proc Details</a></header><main><h1>Song datum <aside>/<a href="datum.html">datum</a>/<a href="datum/song.html">song</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L11"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 11"></a></h1><p>These are the actual backend behind instruments.
They attach to an atom and provide the editor + playback functionality.</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/song.html#var/allowed_instrument_ids">allowed_instrument_ids</a></th><td>What instruments our built in picker can use. The picker won't show unless this is longer than one.</td></tr><tr><th><a href="datum/song.html#var/cached_exponential_dropoff">cached_exponential_dropoff</a></th><td>Do not directly set, use update_sustain()</td></tr><tr><th><a href="datum/song.html#var/cached_legacy_dir">cached_legacy_dir</a></th><td>Cached legacy dir for legacy instruments</td></tr><tr><th><a href="datum/song.html#var/cached_legacy_ext">cached_legacy_ext</a></th><td>Cached legacy ext for legacy instruments</td></tr><tr><th><a href="datum/song.html#var/cached_linear_dropoff">cached_linear_dropoff</a></th><td>/////// DO NOT DIRECTLY SET THESE!
Do not directly set, use update_sustain()</td></tr><tr><th><a href="datum/song.html#var/cached_samples">cached_samples</a></th><td>Cached list of samples, referenced directly from the instrument for synthesized instruments</td></tr><tr><th><a href="datum/song.html#var/channels_idle">channels_idle</a></th><td>List of channels that aren't being used, as text. This is to prevent unnecessary freeing and reallocations from SSsounds/SSinstruments.</td></tr><tr><th><a href="datum/song.html#var/channels_playing">channels_playing</a></th><td>Channel as text = current volume percentage but it's 0 to 100 instead of 0 to 1.</td></tr><tr><th><a href="datum/song.html#var/compiled_chords">compiled_chords</a></th><td>Playing variables
Build by compile_chords()
Must be rebuilt on instrument switch.
Compilation happens when we start playing and is cleared after we finish playing.
Format: list of chord lists, with chordlists having (key1, key2, key3, tempodiv)</td></tr><tr><th><a href="datum/song.html#var/current_chord">current_chord</a></th><td>Current chord we're on.</td></tr><tr><th><a href="datum/song.html#var/debug_mode">debug_mode</a></th><td>If this is enabled, some things won't be strictly cleared when they usually are (liked compiled_chords on play stop)</td></tr><tr><th><a href="datum/song.html#var/delay_by">delay_by</a></th><td>Amount of delay to wait before playing the next chord</td></tr><tr><th><a href="datum/song.html#var/editing">editing</a></th><td>Are we currently editing?</td></tr><tr><th><a href="datum/song.html#var/elapsed_delay">elapsed_delay</a></th><td>Current section of a long chord we're on, so we don't need to make a billion chords, one for every unit ticklag.</td></tr><tr><th><a href="datum/song.html#var/full_sustain_held_note">full_sustain_held_note</a></th><td>Should we not decay our last played note?</td></tr><tr><th><a href="datum/song.html#var/hearing_mobs">hearing_mobs</a></th><td>The list of mobs that can hear us</td></tr><tr><th><a href="datum/song.html#var/help">help</a></th><td>Is the help screen open?</td></tr><tr><th><a href="datum/song.html#var/instrument_range">instrument_range</a></th><td>How far we can be heard</td></tr><tr><th><a href="datum/song.html#var/last_channel_played">last_channel_played</a></th><td>Last channel to play. text.</td></tr><tr><th><a href="datum/song.html#var/last_hearcheck">last_hearcheck</a></th><td>Last world.time we checked for who can hear us</td></tr><tr><th><a href="datum/song.html#var/legacy">legacy</a></th><td>Are we operating in legacy mode (so if the instrument is a legacy instrument)</td></tr><tr><th><a href="datum/song.html#var/lines">lines</a></th><td>Our song lines</td></tr><tr><th><a href="datum/song.html#var/max_repeats">max_repeats</a></th><td>Maximum times we can repeat</td></tr><tr><th><a href="datum/song.html#var/max_sound_channels">max_sound_channels</a></th><td>Max sound channels to occupy</td></tr><tr><th><a href="datum/song.html#var/max_volume">max_volume</a></th><td>Max volume</td></tr><tr><th><a href="datum/song.html#var/min_volume">min_volume</a></th><td>Min volume - This is so someone doesn't decide it's funny to set it to 0 and play invisible songs.</td></tr><tr><th><a href="datum/song.html#var/name">name</a></th><td>Name of the song</td></tr><tr><th><a href="datum/song.html#var/note_shift">note_shift</a></th><td>////////// !!FUN!! - Only works in synthesized mode! /////////////////
Note numbers to shift.</td></tr><tr><th><a href="datum/song.html#var/octave_min">octave_min</a></th><td>DO NOT TOUCH THESE</td></tr><tr><th><a href="datum/song.html#var/parent">parent</a></th><td>The atom we're attached to/playing from</td></tr><tr><th><a href="datum/song.html#var/playing">playing</a></th><td>Are we currently playing?</td></tr><tr><th><a href="datum/song.html#var/repeat">repeat</a></th><td>Repeats left</td></tr><tr><th><a href="datum/song.html#var/sustain_dropoff_volume">sustain_dropoff_volume</a></th><td>When a note is considered dead if it is below this in volume</td></tr><tr><th><a href="datum/song.html#var/sustain_exponential_dropoff">sustain_exponential_dropoff</a></th><td>Exponential sustain dropoff rate per decisecond</td></tr><tr><th><a href="datum/song.html#var/sustain_linear_duration">sustain_linear_duration</a></th><td>Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF</td></tr><tr><th><a href="datum/song.html#var/sustain_mode">sustain_mode</a></th><td>The kind of sustain we're using</td></tr><tr><th><a href="datum/song.html#var/tempo">tempo</a></th><td>delay between notes in deciseconds</td></tr><tr><th><a href="datum/song.html#var/user_playing">user_playing</a></th><td>Person playing us</td></tr><tr><th><a href="datum/song.html#var/using_instrument">using_instrument</a></th><td>///////// Cached instrument variables /////////////
Instrument we are currently using</td></tr><tr><th><a href="datum/song.html#var/using_sound_channels">using_sound_channels</a></th><td>Current channels, so we can save a length() call.</td></tr><tr><th><a href="datum/song.html#var/volume">volume</a></th><td>Our volume</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/song.html#proc/compile_chords">compile_chords</a></th><td>Compiles chords.</td></tr><tr><th><a href="datum/song.html#proc/compile_legacy">compile_legacy</a></th><td>Compiles our lines into &quot;chords&quot; with filenames for legacy playback. This makes there have to be a bit of lag at the beginning of the song, but repeats will not have to parse it again, and overall playback won't be impacted by as much lag.</td></tr><tr><th><a href="datum/song.html#proc/compile_synthesized">compile_synthesized</a></th><td>Compiles our lines into &quot;chords&quot; with numbers. This makes there have to be a bit of lag at the beginning of the song, but repeats will not have to parse it again, and overall playback won't be impacted by as much lag.</td></tr><tr><th><a href="datum/song.html#proc/do_hearcheck">do_hearcheck</a></th><td>Checks and stores which mobs can hear us. Terminates sounds for mobs that leave our range.</td></tr><tr><th><a href="datum/song.html#proc/get_bpm">get_bpm</a></th><td>Gets our beats per minute based on our tempo.</td></tr><tr><th><a href="datum/song.html#proc/play_chord">play_chord</a></th><td>Plays a chord.</td></tr><tr><th><a href="datum/song.html#proc/playkey_legacy">playkey_legacy</a></th><td>Proc to play a legacy note. Just plays the sound to hearing mobs (and does hearcheck if necessary), no fancy channel/sustain/management.</td></tr><tr><th><a href="datum/song.html#proc/playkey_synth">playkey_synth</a></th><td>Plays a specific numerical key from our instrument to anyone who can hear us.
Does a hearing check if enough time has passed.</td></tr><tr><th><a href="datum/song.html#proc/pop_channel">pop_channel</a></th><td>Pops a channel we have reserved so we don't have to release and re-request them from SSsounds every time we play a note. This is faster.</td></tr><tr><th><a href="datum/song.html#proc/process_decay">process_decay</a></th><td>Decays our channels and updates their volumes to mobs who can hear us.</td></tr><tr><th><a href="datum/song.html#proc/process_song">process_song</a></th><td>Processes our song.</td></tr><tr><th><a href="datum/song.html#proc/sanitize_tempo">sanitize_tempo</a></th><td>Sanitizes tempo to a value that makes sense and fits the current world.tick_lag.</td></tr><tr><th><a href="datum/song.html#proc/set_bpm">set_bpm</a></th><td>Sets our tempo from a beats-per-minute, sanitizing it to a valid number first.</td></tr><tr><th><a href="datum/song.html#proc/set_dropoff_volume">set_dropoff_volume</a></th><td>Setter for setting how low the volume has to get before a note is considered &quot;dead&quot; and dropped</td></tr><tr><th><a href="datum/song.html#proc/set_exponential_drop_rate">set_exponential_drop_rate</a></th><td>Setter for setting exponential falloff factor.</td></tr><tr><th><a href="datum/song.html#proc/set_instrument">set_instrument</a></th><td>Sets our instrument, caching anything necessary for faster accessing. Accepts an ID, typepath, or instantiated instrument datum.</td></tr><tr><th><a href="datum/song.html#proc/set_linear_falloff_duration">set_linear_falloff_duration</a></th><td>Setter for setting linear falloff duration.</td></tr><tr><th><a href="datum/song.html#proc/set_volume">set_volume</a></th><td>Setter for setting output volume.</td></tr><tr><th><a href="datum/song.html#proc/should_stop_playing">should_stop_playing</a></th><td>Checks if we should halt playback.</td></tr><tr><th><a href="datum/song.html#proc/start_playing">start_playing</a></th><td>Attempts to start playing our song.</td></tr><tr><th><a href="datum/song.html#proc/stop_playing">stop_playing</a></th><td>Stops playing, terminating all sounds if in synthesized mode. Clears hearing_mobs.</td></tr><tr><th><a href="datum/song.html#proc/tempodiv_to_delay">tempodiv_to_delay</a></th><td>Converts a tempodiv to ticks to elapse before playing the next chord, taking into account our tempo.</td></tr><tr><th><a href="datum/song.html#proc/terminate_all_sounds">terminate_all_sounds</a></th><td>Stops all sounds we are &quot;responsible&quot; for. Only works in synthesized mode.</td></tr><tr><th><a href="datum/song.html#proc/terminate_sound_mob">terminate_sound_mob</a></th><td>Stops all sounds we are responsible for in a given person. Only works in synthesized mode.</td></tr><tr><th><a href="datum/song.html#proc/updateDialog">updateDialog</a></th><td>Updates the window for our users. Override down the line.</td></tr><tr><th><a href="datum/song.html#proc/update_sustain">update_sustain</a></th><td>Updates our cached linear/exponential falloff stuff, saving calculations down the line.</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/allowed_instrument_ids"><aside class="declaration">var </aside>allowed_instrument_ids <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L48"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 48"></a></h3><p>What instruments our built in picker can use. The picker won't show unless this is longer than one.</p><h3 id="var/cached_exponential_dropoff"><aside class="declaration">var </aside>cached_exponential_dropoff <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L127"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 127"></a></h3><p>Do not directly set, use update_sustain()</p><h3 id="var/cached_legacy_dir"><aside class="declaration">var </aside>cached_legacy_dir <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L56"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 56"></a></h3><p>Cached legacy dir for legacy instruments</p><h3 id="var/cached_legacy_ext"><aside class="declaration">var </aside>cached_legacy_ext <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L54"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 54"></a></h3><p>Cached legacy ext for legacy instruments</p><h3 id="var/cached_linear_dropoff"><aside class="declaration">var </aside>cached_linear_dropoff <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L125"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 125"></a></h3><p>/////// DO NOT DIRECTLY SET THESE!
Do not directly set, use update_sustain()</p><h3 id="var/cached_samples"><aside class="declaration">var </aside>cached_samples <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L58"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 58"></a></h3><p>Cached list of samples, referenced directly from the instrument for synthesized instruments</p><h3 id="var/channels_idle"><aside class="declaration">var </aside>channels_idle <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L80"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 80"></a></h3><p>List of channels that aren't being used, as text. This is to prevent unnecessary freeing and reallocations from SSsounds/SSinstruments.</p><h3 id="var/channels_playing"><aside class="declaration">var </aside>channels_playing <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L78"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 78"></a></h3><p>Channel as text = current volume percentage but it's 0 to 100 instead of 0 to 1.</p><h3 id="var/compiled_chords"><aside class="declaration">var </aside>compiled_chords <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L70"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 70"></a></h3><p>Playing variables
Build by compile_chords()
Must be rebuilt on instrument switch.
Compilation happens when we start playing and is cleared after we finish playing.
Format: list of chord lists, with chordlists having (key1, key2, key3, tempodiv)</p><h3 id="var/current_chord"><aside class="declaration">var </aside>current_chord <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L76"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 76"></a></h3><p>Current chord we're on.</p><h3 id="var/debug_mode"><aside class="declaration">var </aside>debug_mode <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L90"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 90"></a></h3><p>If this is enabled, some things won't be strictly cleared when they usually are (liked compiled_chords on play stop)</p><h3 id="var/delay_by"><aside class="declaration">var </aside>delay_by <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L74"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 74"></a></h3><p>Amount of delay to wait before playing the next chord</p><h3 id="var/editing"><aside class="declaration">var </aside>editing <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L31"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 31"></a></h3><p>Are we currently editing?</p><h3 id="var/elapsed_delay"><aside class="declaration">var </aside>elapsed_delay <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L72"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 72"></a></h3><p>Current section of a long chord we're on, so we don't need to make a billion chords, one for every unit ticklag.</p><h3 id="var/full_sustain_held_note"><aside class="declaration">var </aside>full_sustain_held_note <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L98"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 98"></a></h3><p>Should we not decay our last played note?</p><h3 id="var/hearing_mobs"><aside class="declaration">var </aside>hearing_mobs <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L88"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 88"></a></h3><p>The list of mobs that can hear us</p><h3 id="var/help"><aside class="declaration">var </aside>help <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L33"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 33"></a></h3><p>Is the help screen open?</p><h3 id="var/instrument_range"><aside class="declaration">var </aside>instrument_range <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L25"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 25"></a></h3><p>How far we can be heard</p><h3 id="var/last_channel_played"><aside class="declaration">var </aside>last_channel_played <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L96"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 96"></a></h3><p>Last channel to play. text.</p><h3 id="var/last_hearcheck"><aside class="declaration">var </aside>last_hearcheck <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L86"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 86"></a></h3><p>Last world.time we checked for who can hear us</p><h3 id="var/legacy"><aside class="declaration">var </aside>legacy <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L60"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 60"></a></h3><p>Are we operating in legacy mode (so if the instrument is a legacy instrument)</p><h3 id="var/lines"><aside class="declaration">var </aside>lines <aside> /list</aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L19"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 19"></a></h3><p>Our song lines</p><h3 id="var/max_repeats"><aside class="declaration">var </aside>max_repeats <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L38"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 38"></a></h3><p>Maximum times we can repeat</p><h3 id="var/max_sound_channels"><aside class="declaration">var </aside>max_sound_channels <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L92"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 92"></a></h3><p>Max sound channels to occupy</p><h3 id="var/max_volume"><aside class="declaration">var </aside>max_volume <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L43"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 43"></a></h3><p>Max volume</p><h3 id="var/min_volume"><aside class="declaration">var </aside>min_volume <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L45"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 45"></a></h3><p>Min volume - This is so someone doesn't decide it's funny to set it to 0 and play invisible songs.</p><h3 id="var/name"><aside class="declaration">var </aside>name <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L13"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 13"></a></h3><p>Name of the song</p><h3 id="var/note_shift"><aside class="declaration">var </aside>note_shift <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L111"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 111"></a></h3><p>////////// !!FUN!! - Only works in synthesized mode! /////////////////
Note numbers to shift.</p><h3 id="var/octave_min"><aside class="declaration">var </aside>octave_min <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L101"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 101"></a></h3><p>DO NOT TOUCH THESE</p><h3 id="var/parent"><aside class="declaration">var </aside>parent <aside> /<a href="atom.html">atom</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L16"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 16"></a></h3><p>The atom we're attached to/playing from</p><h3 id="var/playing"><aside class="declaration">var </aside>playing <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L28"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 28"></a></h3><p>Are we currently playing?</p><h3 id="var/repeat"><aside class="declaration">var </aside>repeat <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L36"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 36"></a></h3><p>Repeats left</p><h3 id="var/sustain_dropoff_volume"><aside class="declaration">var </aside>sustain_dropoff_volume <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L118"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 118"></a></h3><p>When a note is considered dead if it is below this in volume</p><h3 id="var/sustain_exponential_dropoff"><aside class="declaration">var </aside>sustain_exponential_dropoff <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L122"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 122"></a></h3><p>Exponential sustain dropoff rate per decisecond</p><h3 id="var/sustain_linear_duration"><aside class="declaration">var </aside>sustain_linear_duration <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L120"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 120"></a></h3><p>Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF</p><h3 id="var/sustain_mode"><aside class="declaration">var </aside>sustain_mode <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L116"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 116"></a></h3><p>The kind of sustain we're using</p><h3 id="var/tempo"><aside class="declaration">var </aside>tempo <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L22"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 22"></a></h3><p>delay between notes in deciseconds</p><h3 id="var/user_playing"><aside class="declaration">var </aside>user_playing <aside> /<a href="mob.html">mob</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L82"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 82"></a></h3><p>Person playing us</p><h3 id="var/using_instrument"><aside class="declaration">var </aside>using_instrument <aside> /<a href="datum.html">datum</a>/<a href="datum/instrument.html">instrument</a></aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L52"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 52"></a></h3><p>///////// Cached instrument variables /////////////
Instrument we are currently using</p><h3 id="var/using_sound_channels"><aside class="declaration">var </aside>using_sound_channels <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L94"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 94"></a></h3><p>Current channels, so we can save a length() call.</p><h3 id="var/volume"><aside class="declaration">var </aside>volume <aside> </aside> <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L41"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 41"></a></h3><p>Our volume</p><h2 id="proc">Proc Details</h2><h3 id="proc/compile_chords"><aside class="declaration">proc </aside>compile_chords<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L272"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 272"></a></aside></h3><p>Compiles chords.</p><h3 id="proc/compile_legacy"><aside class="declaration">proc </aside>compile_legacy<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_legacy.dm#L4"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_legacy.dm 4"></a></aside></h3><p>Compiles our lines into &quot;chords&quot; with filenames for legacy playback. This makes there have to be a bit of lag at the beginning of the song, but repeats will not have to parse it again, and overall playback won't be impacted by as much lag.</p><h3 id="proc/compile_synthesized"><aside class="declaration">proc </aside>compile_synthesized<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L4"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 4"></a></aside></h3><p>Compiles our lines into &quot;chords&quot; with numbers. This makes there have to be a bit of lag at the beginning of the song, but repeats will not have to parse it again, and overall playback won't be impacted by as much lag.</p><h3 id="proc/do_hearcheck"><aside class="declaration">proc </aside>do_hearcheck<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L157"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 157"></a></aside></h3><p>Checks and stores which mobs can hear us. Terminates sounds for mobs that leave our range.</p><h3 id="proc/get_bpm"><aside class="declaration">proc </aside>get_bpm<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L299"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 299"></a></aside></h3><p>Gets our beats per minute based on our tempo.</p><h3 id="proc/play_chord"><aside class="declaration">proc </aside>play_chord<aside>(/list/chord) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L278"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 278"></a></aside></h3><p>Plays a chord.</p><h3 id="proc/playkey_legacy"><aside class="declaration">proc </aside>playkey_legacy<aside>(note, acc, oct, /<a href="mob.html">mob</a>/user) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_legacy.dm#L49"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_legacy.dm 49"></a></aside></h3><p>Proc to play a legacy note. Just plays the sound to hearing mobs (and does hearcheck if necessary), no fancy channel/sustain/management.</p>
<p>Arguments:</p>
<ul>
<li>note is a number from 1-7 for A-G</li>
<li>acc is either &quot;b&quot;, &quot;n&quot;, or &quot;#&quot;</li>
<li>oct is 1-8 (or 9 for C)</li>
</ul><h3 id="proc/playkey_synth"><aside class="declaration">proc </aside>playkey_synth<aside>(key, /<a href="mob.html">mob</a>/user) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L45"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 45"></a></aside></h3><p>Plays a specific numerical key from our instrument to anyone who can hear us.
Does a hearing check if enough time has passed.</p><h3 id="proc/pop_channel"><aside class="declaration">proc </aside>pop_channel<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L91"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 91"></a></aside></h3><p>Pops a channel we have reserved so we don't have to release and re-request them from SSsounds every time we play a note. This is faster.</p><h3 id="proc/process_decay"><aside class="declaration">proc </aside>process_decay<aside>(wait_ds) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L108"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 108"></a></aside></h3><p>Decays our channels and updates their volumes to mobs who can hear us.</p>
<p>Arguments:</p>
<ul>
<li>wait_ds - the deciseconds we should decay by. This is to compensate for any lag, as otherwise songs would get pretty nasty during high time dilation.</li>
</ul><h3 id="proc/process_song"><aside class="declaration">proc </aside>process_song<aside>(wait) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L242"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 242"></a></aside></h3><p>Processes our song.</p><h3 id="proc/sanitize_tempo"><aside class="declaration">proc </aside>sanitize_tempo<aside>(new_tempo) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L292"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 292"></a></aside></h3><p>Sanitizes tempo to a value that makes sense and fits the current world.tick_lag.</p><h3 id="proc/set_bpm"><aside class="declaration">proc </aside>set_bpm<aside>(bpm) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L305"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 305"></a></aside></h3><p>Sets our tempo from a beats-per-minute, sanitizing it to a valid number first.</p><h3 id="proc/set_dropoff_volume"><aside class="declaration">proc </aside>set_dropoff_volume<aside>(volume) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L344"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 344"></a></aside></h3><p>Setter for setting how low the volume has to get before a note is considered &quot;dead&quot; and dropped</p><h3 id="proc/set_exponential_drop_rate"><aside class="declaration">proc </aside>set_exponential_drop_rate<aside>(drop) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L352"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 352"></a></aside></h3><p>Setter for setting exponential falloff factor.</p><h3 id="proc/set_instrument"><aside class="declaration">proc </aside>set_instrument<aside>(/<a href="datum.html">datum</a>/<a href="datum/instrument.html">instrument</a>/I) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L173"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 173"></a></aside></h3><p>Sets our instrument, caching anything necessary for faster accessing. Accepts an ID, typepath, or instantiated instrument datum.</p><h3 id="proc/set_linear_falloff_duration"><aside class="declaration">proc </aside>set_linear_falloff_duration<aside>(duration) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L360"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 360"></a></aside></h3><p>Setter for setting linear falloff duration.</p><h3 id="proc/set_volume"><aside class="declaration">proc </aside>set_volume<aside>(volume) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L336"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 336"></a></aside></h3><p>Setter for setting output volume.</p><h3 id="proc/should_stop_playing"><aside class="declaration">proc </aside>should_stop_playing<aside>(/<a href="mob.html">mob</a>/user) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L286"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 286"></a></aside></h3><p>Checks if we should halt playback.</p><h3 id="proc/start_playing"><aside class="declaration">proc </aside>start_playing<aside>(/<a href="mob.html">mob</a>/user) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L204"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 204"></a></aside></h3><p>Attempts to start playing our song.</p><h3 id="proc/stop_playing"><aside class="declaration">proc </aside>stop_playing<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L228"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 228"></a></aside></h3><p>Stops playing, terminating all sounds if in synthesized mode. Clears hearing_mobs.</p><h3 id="proc/tempodiv_to_delay"><aside class="declaration">proc </aside>tempodiv_to_delay<aside>(tempodiv) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L264"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 264"></a></aside></h3><p>Converts a tempodiv to ticks to elapse before playing the next chord, taking into account our tempo.</p><h3 id="proc/terminate_all_sounds"><aside class="declaration">proc </aside>terminate_all_sounds<aside>(clear_channels) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L71"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 71"></a></aside></h3><p>Stops all sounds we are &quot;responsible&quot; for. Only works in synthesized mode.</p><h3 id="proc/terminate_sound_mob"><aside class="declaration">proc </aside>terminate_sound_mob<aside>(/<a href="mob.html">mob</a>/M) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/play_synthesized.dm#L84"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/play_synthesized.dm 84"></a></aside></h3><p>Stops all sounds we are responsible for in a given person. Only works in synthesized mode.</p><h3 id="proc/updateDialog"><aside class="declaration">proc </aside>updateDialog<aside>(/<a href="mob.html">mob</a>/user) <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L311"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 311"></a></aside></h3><p>Updates the window for our users. Override down the line.</p><h3 id="proc/update_sustain"><aside class="declaration">proc </aside>update_sustain<aside>() <a href="https://github.com/evilew/GS13-Citadel/blob/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e/code/modules/instruments/songs/_song.dm#L324"><img src="git.png" width="16" height="16" title="code/modules/instruments/songs/_song.dm 324"></a></aside></h3><p>Updates our cached linear/exponential falloff stuff, saving calculations down the line.</p></main><footer>tgstation.dme <a href="https://github.com/evilew/GS13-Citadel/tree/e8e0068531dd988f9e65b33ae7866d4fbf1fdd9e">e8e0068</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.9.0</a></footer></body></html>