Song datum
These are the actual backend behind instruments. They attach to an atom and provide the editor + playback functionality.
Vars | |
allowed_instrument_ids | What instruments our built in picker can use. The picker won't show unless this is longer than one. |
---|---|
cached_exponential_dropoff | Do not directly set, use update_sustain() |
cached_legacy_dir | Cached legacy dir for legacy instruments |
cached_legacy_ext | Cached legacy ext for legacy instruments |
cached_linear_dropoff | /////// DO NOT DIRECTLY SET THESE! Do not directly set, use update_sustain() |
cached_samples | Cached list of samples, referenced directly from the instrument for synthesized instruments |
channels_idle | List of channels that aren't being used, as text. This is to prevent unnecessary freeing and reallocations from SSsounds/SSinstruments. |
channels_playing | Channel as text = current volume percentage but it's 0 to 100 instead of 0 to 1. |
compiled_chords | 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) |
current_chord | Current chord we're on. |
debug_mode | If this is enabled, some things won't be strictly cleared when they usually are (liked compiled_chords on play stop) |
delay_by | Amount of delay to wait before playing the next chord |
editing | Are we currently editing? |
elapsed_delay | Current section of a long chord we're on, so we don't need to make a billion chords, one for every unit ticklag. |
full_sustain_held_note | Should we not decay our last played note? |
hearing_mobs | The list of mobs that can hear us |
help | Is the help screen open? |
instrument_range | How far we can be heard |
last_channel_played | Last channel to play. text. |
last_hearcheck | Last world.time we checked for who can hear us |
legacy | Are we operating in legacy mode (so if the instrument is a legacy instrument) |
lines | Our song lines |
max_repeats | Maximum times we can repeat |
max_sound_channels | Max sound channels to occupy |
max_volume | Max volume |
min_volume | Min volume - This is so someone doesn't decide it's funny to set it to 0 and play invisible songs. |
music_player | Who or what's playing us |
name | Name of the song |
note_shift | ////////// !!FUN!! - Only works in synthesized mode! ///////////////// Note numbers to shift. |
octave_min | DO NOT TOUCH THESE |
parent | The atom we're attached to/playing from |
playing | Are we currently playing? |
repeat | Repeats left |
sustain_dropoff_volume | When a note is considered dead if it is below this in volume |
sustain_exponential_dropoff | Exponential sustain dropoff rate per decisecond |
sustain_linear_duration | Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF |
sustain_mode | The kind of sustain we're using |
tempo | delay between notes in deciseconds |
using_instrument | ///////// Cached instrument variables ///////////// Instrument we are currently using |
using_sound_channels | Current channels, so we can save a length() call. |
volume | Our volume |
Procs | |
ParseSong | Parses a song the user has input into lines and stores them. |
compile_chords | Compiles chords. |
compile_legacy | Compiles our lines into "chords" 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. |
compile_synthesized | Compiles our lines into "chords" 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. |
do_hearcheck | Checks and stores which mobs can hear us. Terminates sounds for mobs that leave our range. |
get_bpm | Gets our beats per minute based on our tempo. |
instrument_status_ui | Returns the HTML for the status UI for this song datum. |
play_chord | Plays a chord. |
playkey_legacy | Proc to play a legacy note. Just plays the sound to hearing mobs (and does hearcheck if necessary), no fancy channel/sustain/management. |
playkey_synth | Plays a specific numerical key from our instrument to anyone who can hear us. Does a hearing check if enough time has passed. |
pop_channel | 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. |
process_decay | Decays our channels and updates their volumes to mobs who can hear us. |
process_song | Processes our song. |
sanitize_tempo | Sanitizes tempo to a value that makes sense and fits the current world.tick_lag. |
set_bpm | Sets our tempo from a beats-per-minute, sanitizing it to a valid number first. |
set_dropoff_volume | Setter for setting how low the volume has to get before a note is considered "dead" and dropped |
set_exponential_drop_rate | Setter for setting exponential falloff factor. |
set_instrument | Sets our instrument, caching anything necessary for faster accessing. Accepts an ID, typepath, or instantiated instrument datum. |
set_linear_falloff_duration | Setter for setting linear falloff duration. |
set_repeats | Sets and sanitizes the repeats variable. |
set_volume | Setter for setting output volume. |
should_stop_playing | Checks if we should halt playback. |
start_playing | Attempts to start playing our song. |
stop_playing | Stops playing, terminating all sounds if in synthesized mode. Clears hearing_mobs. |
tempodiv_to_delay | Converts a tempodiv to ticks to elapse before playing the next chord, taking into account our tempo. |
terminate_all_sounds | Stops all sounds we are "responsible" for. Only works in synthesized mode. |
terminate_sound_mob | Stops all sounds we are responsible for in a given person. Only works in synthesized mode. |
updateDialog | Updates the window for our users. Override down the line. |
update_sustain | Updates our cached linear/exponential falloff stuff, saving calculations down the line. |
Var Details
allowed_instrument_ids
What instruments our built in picker can use. The picker won't show unless this is longer than one.
cached_exponential_dropoff
Do not directly set, use update_sustain()
cached_legacy_dir
Cached legacy dir for legacy instruments
cached_legacy_ext
Cached legacy ext for legacy instruments
cached_linear_dropoff
/////// DO NOT DIRECTLY SET THESE! Do not directly set, use update_sustain()
cached_samples
Cached list of samples, referenced directly from the instrument for synthesized instruments
channels_idle
List of channels that aren't being used, as text. This is to prevent unnecessary freeing and reallocations from SSsounds/SSinstruments.
channels_playing
Channel as text = current volume percentage but it's 0 to 100 instead of 0 to 1.
compiled_chords
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)
current_chord
Current chord we're on.
debug_mode
If this is enabled, some things won't be strictly cleared when they usually are (liked compiled_chords on play stop)
delay_by
Amount of delay to wait before playing the next chord
editing
Are we currently editing?
elapsed_delay
Current section of a long chord we're on, so we don't need to make a billion chords, one for every unit ticklag.
full_sustain_held_note
Should we not decay our last played note?
hearing_mobs
The list of mobs that can hear us
help
Is the help screen open?
instrument_range
How far we can be heard
last_channel_played
Last channel to play. text.
last_hearcheck
Last world.time we checked for who can hear us
legacy
Are we operating in legacy mode (so if the instrument is a legacy instrument)
lines
Our song lines
max_repeats
Maximum times we can repeat
max_sound_channels
Max sound channels to occupy
max_volume
Max volume
min_volume
Min volume - This is so someone doesn't decide it's funny to set it to 0 and play invisible songs.
music_player
Who or what's playing us
name
Name of the song
note_shift
////////// !!FUN!! - Only works in synthesized mode! ///////////////// Note numbers to shift.
octave_min
DO NOT TOUCH THESE
parent
The atom we're attached to/playing from
playing
Are we currently playing?
repeat
Repeats left
sustain_dropoff_volume
When a note is considered dead if it is below this in volume
sustain_exponential_dropoff
Exponential sustain dropoff rate per decisecond
sustain_linear_duration
Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF
sustain_mode
The kind of sustain we're using
tempo
delay between notes in deciseconds
using_instrument
///////// Cached instrument variables ///////////// Instrument we are currently using
using_sound_channels
Current channels, so we can save a length() call.
volume
Our volume
Proc Details
ParseSong
Parses a song the user has input into lines and stores them.
compile_chords
Compiles chords.
compile_legacy
Compiles our lines into "chords" 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.
compile_synthesized
Compiles our lines into "chords" 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.
do_hearcheck
Checks and stores which mobs can hear us. Terminates sounds for mobs that leave our range.
get_bpm
Gets our beats per minute based on our tempo.
instrument_status_ui
Returns the HTML for the status UI for this song datum.
play_chord
Plays a chord.
playkey_legacy
Proc to play a legacy note. Just plays the sound to hearing mobs (and does hearcheck if necessary), no fancy channel/sustain/management.
Arguments:
- note is a number from 1-7 for A-G
- acc is either "b", "n", or "#"
- oct is 1-8 (or 9 for C)
playkey_synth
Plays a specific numerical key from our instrument to anyone who can hear us. Does a hearing check if enough time has passed.
pop_channel
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.
process_decay
Decays our channels and updates their volumes to mobs who can hear us.
Arguments:
- 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.
process_song
Processes our song.
sanitize_tempo
Sanitizes tempo to a value that makes sense and fits the current world.tick_lag.
set_bpm
Sets our tempo from a beats-per-minute, sanitizing it to a valid number first.
set_dropoff_volume
Setter for setting how low the volume has to get before a note is considered "dead" and dropped
set_exponential_drop_rate
Setter for setting exponential falloff factor.
set_instrument
Sets our instrument, caching anything necessary for faster accessing. Accepts an ID, typepath, or instantiated instrument datum.
set_linear_falloff_duration
Setter for setting linear falloff duration.
set_repeats
Sets and sanitizes the repeats variable.
set_volume
Setter for setting output volume.
should_stop_playing
Checks if we should halt playback.
start_playing
Attempts to start playing our song.
stop_playing
Stops playing, terminating all sounds if in synthesized mode. Clears hearing_mobs.
Arguments:
- finished: boolean, whether the song ended via reaching the end.
tempodiv_to_delay
Converts a tempodiv to ticks to elapse before playing the next chord, taking into account our tempo.
terminate_all_sounds
Stops all sounds we are "responsible" for. Only works in synthesized mode.
terminate_sound_mob
Stops all sounds we are responsible for in a given person. Only works in synthesized mode.
updateDialog
Updates the window for our users. Override down the line.
update_sustain
Updates our cached linear/exponential falloff stuff, saving calculations down the line.