Sound operators: Difference between revisions
Jump to navigation
Jump to search
(.) |
TeamSpen210 (talk | contribs) (Document most of the operators.) |
||
Line 1: | Line 1: | ||
These are the root sound operators referenced in [[Portal 2]]. See <code>scripts/sound_operator_stacks.txt</code> and [[Soundscripts#Operator stacks ]] for more details. | These are the root sound operators referenced in [[Portal 2]]. See <code>scripts/sound_operator_stacks.txt</code> and [[Soundscripts#Operator stacks ]] for more details. | ||
To chain operators together, values can be set to <code>@prev_op_name.property_name</code> to read a value. For vectors the names can be appended with an index in square brackets to set/get a specific value. | |||
{{todo|Make this more beginner-friendy?}} | {{todo|Make this more beginner-friendy?}} | ||
Line 137: | Line 139: | ||
:; <code>input</code> | :; <code>input</code> | ||
:: [[Floating point]] value to set. | :: [[Floating point]] value to set. | ||
=== Maths === | === Maths === | ||
''Generate or process numbers.'' | ''Generate or process numbers.'' | ||
The result of these is stored in <code>@name.output</code>. | |||
; <code>math_random</code> | ; <code>math_random</code> | ||
: Produces a random number | : Produces a random number. | ||
:; <code>input_min</code> | :; <code>input_min</code> | ||
:; <code>input_max</code> | :; <code>input_max</code> | ||
:: Range of values to output. | :: Range of values to output. | ||
* math_float | :; <code>round_to_int</code> | ||
:: Set to <code>"true"</code> or <code>"false"</code>(default). This makes the output a whole number. | |||
; <code>math_float</code> | |||
: Performs elementary maths operations with two values. | |||
:; <code>input1</code> | |||
:; <code>input2</code> | |||
:: The two operands to use. | |||
:; <code>apply</code> | |||
:: Specifies the operation to perform: | |||
::; <code>add</code> | |||
::: A + B | |||
::; <code>sub</code> | |||
::: A - B | |||
::; <code>mult</code> | |||
::: A * B | |||
::; <code>div</code> | |||
::: A / B | |||
::; <code>mod</code> | |||
::: Returns the remainder of A / B, or the modulus. | |||
::; <code>invert_scale</code> | |||
::: Unknown behaviour. Always performed on the output of cos(), and then used to multiply another value. | |||
::; <code>min</code> | |||
::: Outputs the smallest of the two numbers. | |||
::; <code>max</code> | |||
::: Outputs the largest of the two numbers. | |||
::; <code>less_than</code> | |||
::: Checks if A < B, and outputs 1.0 or 0.0. | |||
::; <code>greater_than</code> | |||
::: Checks if A > B, and outputs 1.0 or 0.0. | |||
::; <code>less_than_or_equal</code> | |||
::: Checks if A <= B, and outputs 1.0 or 0.0. | |||
::; <code>greater_than_or_equal</code> | |||
::: Checks if A >= B, and outputs 1.0 or 0.0. | |||
::; <code>equals</code> | |||
::: If both are equal outputs 1.0, otherwise 0.0 | |||
; math_float_accumulate12 | |||
: Does the same as <code>math_float</code>, but uses 12 inputs instead. All examples use <code>mult</code>. | |||
; math_func1 | |||
: Executes various maths functions. | |||
:; <code>input1</code> | |||
:: The argument to pass. | |||
:; <code>function</code> | |||
:: Specifies the function to call: | |||
::; <code>round</code> | |||
::: Round to the nearest whole number. | |||
::; <code>fabs</code> | |||
::: Compute the absolute value of the input. | |||
::; <code>sqrt</code> | |||
::: Computes the square root of the input. | |||
::; <code>exp</code> | |||
::: Computes e raised to the power of the input. | |||
::; <code>log</code> | |||
::: Computes the natural logarithm of the input. | |||
::; <code>sin</code> | |||
::; <code>cos</code> | |||
::; <code>tan</code> | |||
::: Computes the normal sin/cos/tan values. Angles are given in radians. | |||
::; <code>asin</code> | |||
::; <code>acos</code> | |||
::; <code>atan</code> | |||
::: Computes the inverse of sin/cos/tan. Angles are given in radians. | |||
:; <code>normalise_trig</code> | |||
:: Set to <code>"true"</code> or <code>"false"</code>. Unknown behaviour, but false computes normal trignometric values. | |||
; math_logic_switch | |||
: Selects one of two possible outputs. | |||
:; <code>input_switch</code> | |||
:: Chooses which of the other values is outputted. | |||
:; <code>input1</code> | |||
:: The value to output if <code>input_switch</code> is <code>0</code>. | |||
:; <code>input2</code> | |||
:: The value to output if <code>input_switch</code> is <code>1</code>. | |||
* math_delta | * math_delta | ||
* math_remap_float | * math_remap_float | ||
: Remaps a value from one range to another (identically to [[math_remap]]). | |||
:; <code>input</code> | |||
:: The value to remap. | |||
:; <code>input_min</code> | |||
:; <code>input_max</code> | |||
:: The smallest/largest value the input will be set to. | |||
:; <code>input_map_min</code> | |||
:: When the input equals <code>input_min</code>, the output will be this value. | |||
:; <code>input_map_max</code> | |||
:: When the input equals <code>input_max</code>, the output will be this value. | |||
=== Getters === | === Getters === | ||
Line 156: | Line 248: | ||
''Provide values from the engine.'' | ''Provide values from the engine.'' | ||
* | ; get_convar | ||
: Retrieve the value of a console variable. | |||
* | :; <code>convar</code> | ||
:: The name of the console variable to read. | |||
* get_dashboard | |||
; <code>get_map_name</code> | |||
: Checks if the given <code>map_name</code> matches the name of the map. | |||
* get_opvar_float | |||
* get_soundmixer | * get_soundmixer | ||
* | * get_track_syncpoint | ||
* | |||
* | ; <code>get_sys_time</code> | ||
: Collects the host/client time. | |||
:; <code>output_client_time</code> | |||
:; <code>output_host_time</code> | |||
; <code>get_entry_time</code> | |||
: Collects information about the playing sound. | |||
:; <code>output_entry_elapsed</code> | |||
:: The time this sound has been playing. | |||
:; <code>output_sound_elapsed</code> | |||
:; <code>output_stop_elapsed</code> | |||
:: -1 if playing, otherwise the time spent after being stopped. | |||
:; <code>output_sound_duration</code> | |||
:: The duration of the current sound. Zero during the start stack. | |||
; <code>get_source_info</code> | |||
: Collects a variety of information about the sound source. | |||
:; <code>source</code> | |||
:: Specify <code>"entity"</code> or <code>"emitter"</code> to choose which entity is checked. The emitter is the entity where the sound emmenates from, the entity is the entity which made it play. | |||
:; <code>output_entity_index</code> | |||
:: The index for this entity. | |||
:; <code>output_position</code> | |||
:: The position of the entity. | |||
:; <code>output_angles</code> | |||
:: The rotation of the entity. | |||
:; <code>output_radius</code> | |||
:: Only valid for the emitter. | |||
:; <code>output_volume</code> | |||
:; <code>output_level</code> | |||
:; output_pitch</code> | |||
:: The relevant values of the soundscript. | |||
:; <code>output_source_count</code> | |||
:: The number of sounds (including this one) produced by the entity. | |||
; <code>game_view_info</code> | |||
: Collects a variety of game-specific information about the player for specialised uses. | |||
:; <code>output_velocity_xy</code> | |||
:; <code>output_velocity_vector_z</code> | |||
:; <code>output_position_x</code> | |||
:; <code>output_position_y</code> | |||
:; <code>output_position_z</code> | |||
:: Returns the vector or X/Y/Z position for the provided <code>input_source_index</code>. | |||
:; <code>output_stop_elapsed</code> | |||
=== Setters === | |||
''Change values in the engine.'' | |||
* set_convar | |||
* set_opvar_float | |||
* increment_opvar_float | |||
=== Calculations === | === Calculations === | ||
Line 172: | Line 319: | ||
* calc_occlusion | * calc_occlusion | ||
* calc_falloff | * calc_falloff | ||
; calc_source_distance | |||
: Calculates the distance from this sound to the provided <code>input_position</code>. | |||
* calc_spatialize_speakers | * calc_spatialize_speakers | ||
=== Other === | === Other === | ||
; <code>util_print_float</code> | |||
: Displays a float in the console, along with the name of this operator. | |||
:; <code>input</code> | |||
:: The floating point value to show. | |||
* util_pos_vec8 | * util_pos_vec8 | ||
* op_accumulate_ss_float | * op_accumulate_ss_float | ||
* iterate_merge_speakers | |||
* track_queue | |||
* track_stop | |||
* track_update | |||
[[Category:Sound System]] | [[Category:Sound System]] |
Revision as of 01:46, 11 March 2019
These are the root sound operators referenced in Portal 2. See scripts/sound_operator_stacks.txt
and Soundscripts#Operator stacks for more details.
To chain operators together, values can be set to @prev_op_name.property_name
to read a value. For vectors the names can be appended with an index in square brackets to set/get a specific value.
Todo: Make this more beginner-friendy?
Usage
VFX.LightFlickerEnd
{
channel CHAN_AUTO
soundlevel SNDLVL_105db
volume 1.0
rndwave
{
wave "vfx/light_flicker/light_flicker_end_01.wav"
wave "vfx/light_flicker/light_flicker_end_02.wav"
wave "vfx/light_flicker/light_flicker_end_03.wav"
wave "vfx/light_flicker/light_flicker_end_04.wav"
}
soundentry_version 2
operator_stacks
{
start_stack // applied when the sound begins
{
import_stack "P2_exclusion_time_blocker_start" // defined in scripts/sound_operator_stacks.txt
// We are now extending/configuring P2_exclusion_time_blocker_start
block_entries // prevents another sound from playing
{
input_duration 0.25 // seconds to block for
match_entry "World.LightFlickerEnd" // the sound entry to block
match_entity false // only on the same entity that this sound is playing from?
}
}
}
}
Common properties
execute_once
- Whether the operator should run every time the stack is evaluated, or only the first time. Output values are presumable stored between executions in the latter case.
input_execute
- The operator will only run if this value is true (i.e. non-zero).
output
- The result of the operator (if there is one). Accessed with
@OperatorName.output
.
There is also one special command that is not an operator:
import_stack
- Inserts another named stack into this one.
Operator list
System
Affect sound playback.
sys_stop_entries
- Ends existing sounds.
match_entry
- The sound entry name to look for.
match_substring
- Whether
match_entry
can be part of a larger string (e.g. "MyGun" matches MyGun.fire, MyGun.reload). match_channel
- Sound must have the same channel (e.g. CHAN_STATIC) as this one to match.
match_entity
- Sound must be coming from the same entity as this one.
input_max_entries
Confirm:Stop all but this many instances of the sound?
sys_start_entry
- Plays another sound.
input_start
Confirm:In addition to whether the operator is active, only start if/when this value is true?
entry_name
- The entry to play.
sys_block_entries
- Prevents new sounds from playing.
input_duration
- How long to suppress sounds for.
input_active
Confirm:In addition to normal duration, suppress only when this value is true?
match_entry
- Sound entry to suppress.
match_sound
- A raw WAV/MP3 filename to match. Possibly deprecated?
match_substring
- Whether
match_entry
can be part of a larger string (e.g. "MyGun" matches MyGun.fire, MyGun.reload). match_channel
- Sound must have the same channel (e.g. CHAN_STATIC) as this one to match.
match_entity
- Sound must be coming from the same entity as this one.
sys_output
- Sends a value back to the sound system relating to the current entry.
input_float
- Takes a float value to send to the system.
input_speakers
- Takes an array of floats to send to the system, each to do with a certain speaker. Use only with the speakers output.
output
- Says what value should be altered, for example:
speakers
- Use in
update_stack
s only. Adjusts the volume of each speaker according to values given byinput_speakers
. pitch
- Use in
update_stack
s only. Adjusts the playback pitch of the sound to the value given withinput_float
. dsp
- Use in
update_stack
s only. Adjusts the DSP of the sound to the value given withinput_float
. delay
- Use in
start_stack
s only. Waits for the number of seconds specified ininput_float
before starting the sound. A negative value results in it starting the sound that many seconds into the WAV file instead of at the beginning. block_start
- Use in
start_stack
s only. Prevents the sound from starting if the value given withinput_float
is non-zero. mixlayer_trigger
- "Tell the mixlayer we're active" if the value given with
input_float
is non-zero. - Todo: What does this mean?
save_restore
Confirm:Use in
update_stack
s only. Tells the system to save and restore the state of the sound if the value given withinput_float
is non-zero.stop_hold
- Use in
update_stack
s only.Confirm:Prevents the sound from stopping if the value given with
input_float
is non-zero. facing
Confirm:Make the sound play in a certain direction?
sys_platform
- Tests what platform the engine is running on.
pc
x360
ps3
- Should the operator return true if running on this platform?
sys_mixlayer
- Configures a sound mixer. See
scripts\soundmixers.txt
mixlayer
- The layer to alter.
mixgroup
- The sound group within the layer to alter.
field
- Property of the group to alter.
input
- Floating point value to set.
Maths
Generate or process numbers.
The result of these is stored in @name.output
.
math_random
- Produces a random number.
input_min
input_max
- Range of values to output.
round_to_int
- Set to
"true"
or"false"
(default). This makes the output a whole number.
math_float
- Performs elementary maths operations with two values.
input1
input2
- The two operands to use.
apply
- Specifies the operation to perform:
add
- A + B
sub
- A - B
mult
- A * B
div
- A / B
mod
- Returns the remainder of A / B, or the modulus.
invert_scale
- Unknown behaviour. Always performed on the output of cos(), and then used to multiply another value.
min
- Outputs the smallest of the two numbers.
max
- Outputs the largest of the two numbers.
less_than
- Checks if A < B, and outputs 1.0 or 0.0.
greater_than
- Checks if A > B, and outputs 1.0 or 0.0.
less_than_or_equal
- Checks if A <= B, and outputs 1.0 or 0.0.
greater_than_or_equal
- Checks if A >= B, and outputs 1.0 or 0.0.
equals
- If both are equal outputs 1.0, otherwise 0.0
- math_float_accumulate12
- Does the same as
math_float
, but uses 12 inputs instead. All examples usemult
.
- math_func1
- Executes various maths functions.
input1
- The argument to pass.
function
- Specifies the function to call:
round
- Round to the nearest whole number.
fabs
- Compute the absolute value of the input.
sqrt
- Computes the square root of the input.
exp
- Computes e raised to the power of the input.
log
- Computes the natural logarithm of the input.
sin
cos
tan
- Computes the normal sin/cos/tan values. Angles are given in radians.
asin
acos
atan
- Computes the inverse of sin/cos/tan. Angles are given in radians.
normalise_trig
- Set to
"true"
or"false"
. Unknown behaviour, but false computes normal trignometric values.
- math_logic_switch
- Selects one of two possible outputs.
input_switch
- Chooses which of the other values is outputted.
input1
- The value to output if
input_switch
is0
. input2
- The value to output if
input_switch
is1
.
- math_delta
- math_remap_float
- Remaps a value from one range to another (identically to math_remap).
input
- The value to remap.
input_min
input_max
- The smallest/largest value the input will be set to.
input_map_min
- When the input equals
input_min
, the output will be this value. input_map_max
- When the input equals
input_max
, the output will be this value.
Getters
Provide values from the engine.
- get_convar
- Retrieve the value of a console variable.
convar
- The name of the console variable to read.
- get_dashboard
get_map_name
- Checks if the given
map_name
matches the name of the map.
- get_opvar_float
- get_soundmixer
- get_track_syncpoint
get_sys_time
- Collects the host/client time.
output_client_time
output_host_time
get_entry_time
- Collects information about the playing sound.
output_entry_elapsed
- The time this sound has been playing.
output_sound_elapsed
output_stop_elapsed
- -1 if playing, otherwise the time spent after being stopped.
output_sound_duration
- The duration of the current sound. Zero during the start stack.
get_source_info
- Collects a variety of information about the sound source.
source
- Specify
"entity"
or"emitter"
to choose which entity is checked. The emitter is the entity where the sound emmenates from, the entity is the entity which made it play. output_entity_index
- The index for this entity.
output_position
- The position of the entity.
output_angles
- The rotation of the entity.
output_radius
- Only valid for the emitter.
output_volume
output_level
- output_pitch
- The relevant values of the soundscript.
output_source_count
- The number of sounds (including this one) produced by the entity.
game_view_info
- Collects a variety of game-specific information about the player for specialised uses.
output_velocity_xy
output_velocity_vector_z
output_position_x
output_position_y
output_position_z
- Returns the vector or X/Y/Z position for the provided
input_source_index
. output_stop_elapsed
Setters
Change values in the engine.
- set_convar
- set_opvar_float
- increment_opvar_float
Calculations
Calculate pre-set algorithms.
- calc_angles_facing
- calc_distant_dsp
- calc_occlusion
- calc_falloff
- calc_source_distance
- Calculates the distance from this sound to the provided
input_position
.
- calc_spatialize_speakers
Other
util_print_float
- Displays a float in the console, along with the name of this operator.
input
- The floating point value to show.
- util_pos_vec8
- op_accumulate_ss_float
- iterate_merge_speakers
- track_queue
- track_stop
- track_update