This article relates to the game "Portal 2". Click here for more information.

Sound operators: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Document other math_func1 operations)
(→‎calc_spatialize_speakers: Described input_radius in more detail.)
 
(35 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{LanguageBar}}
{{P2 topicon}}
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.
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?}}


== Usage ==
== Usage ==
<source lang=php highlight=14-31>
<source lang=php highlight=14-31>
VFX.LightFlickerEnd  
VFX.LightFlickerEnd  
Line 43: Line 45:


== Common properties ==
== Common properties ==
; <code>execute_once</code>
; <code>execute_once</code>
: 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.
: 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.
Line 57: Line 58:


== Operator list ==
== Operator list ==
=== System ===
=== System ===
''Affect sound playback.''
''Affect sound playback.''


==== sys_stop_entries ====
==== sys_stop_entries ====
: Ends existing sounds.
Finds currently playing sounds and stops the matching ones, optionally with a delay. Its essential properties are <code>match_entry</code> and/or <code>match_sound</code> to specify one or more sounds to stop.
:; <code>input_execute</code> <[[float]]>
{| class=wikitable
:: Will execute this operation if its value is greater than <code>0.0</code>. Default value is <code>1.0</code>
! Input Name
:; <code>input_max_entries</code> <[[float]]>
! Type
:: Amount of instances allowed to play before one of the instances is stopped and replaced by a new instance of the sound entry.
! Default
:; <code>input_stop_delay</code> <[[float]]>
! Description
:: Adds a delay before an instance of the sound entry is stopped.
|-
:; <code>match_entry</code> <[[string]]>
| <code>input_execute</code> || [[float]] || 1.0
:: The sound entry name to look for.
| If set to a value smaller or equal to <code>0.0</code>, no stopping is performed.
:; <code>output_entries_matching</code>
|-
:: {{Confirm|Outputs the number of entries matching the defined entry.}}
| <code>input_max_entries</code> || [[float]] || 1.0
::: ''Usage: <code>"input1"</code>(of a separate operation) <code>"@your_stop_entry_operation.output_entries_matching"</code>''
| If set to <code>x</code>, stops as many matching sounds until there are less than <code>x</code> of them still playing. This usually does not include the new instance of the sound entry containing this operator: When used in a <code>start_stack</code> to stop instances of itself, setting this to <code>n</code> allows up to <code>n+1</code> instances playing simultaneously.
:; <code>output_this_matches_index</code>
{{note|The default value is 1, which stops all '''but one''' matches. Set to 0 to stop all matches.}}
:: Uncertain. It's an output so it'd be used in the same manner as <code>output_entries_matching</code>.
|-
:; <code>match_sound</code> <[[string]]>
| <code>input_stop_delay</code> || [[float]] || 0.0
:: Match the name of the audio file.
| If some instance of a sound entry will be stopped, then with this delay in seconds.
:: {{Confirm| Is the path needed or just the audio file name and format?}}
|-
:; <code>match_substring</code> <[[bool]]>
| <code>match_entry</code> || [[string]] || ""
:: Whether <code>match_entry</code> can be part of a larger string (e.g. "MyGun" matches MyGun.fire, MyGun.reload).
| If this is not the empty string, matches only sounds that originate from a sound entry with this exact name (not case sensitive). If <code>match_substring</code> is set to true, matches all sounds whose sound entry name ''contains'' the specified string.
:; <code>match_channel</code> <[[bool]]>
|-
:: Sound must have the same channel (e.g. CHAN_STATIC) as this one to match.
| <code>match_sound</code> || [[string]] || ""
:; <code>match_entity</code> <[[bool]]>
| If this is not the empty string, matches only sounds where the string of the path of their audio file equals the specified string (not case sensitive). For currently playing sounds, it's the path shown at the top right of the screen when {{cmd|snd_show|1}} is set, which means that the string includes preceding [[Soundscripts#Sound characters|sound characters]] as well as backslashes <code>\</code> between directories ('''not''' forward slashes <code>/</code>).<br>If the property <code>match_substring</code> is true, all entries will be matched that ''contain'' this string in their path string.
:: Sound must be coming from the same entity as this one.
|-
:; <code>stop_oldest</code> <[[bool]]>
| <code>match_substring</code> || [[bool]] || false
:: Stops the oldest instance of the sound entry.
| Alters the matches for both <code>match_entry</code> and <code>match_sound</code>. If set to false, those strings must be exactly equal. For example, if set to true, <code>MyGun</code> matches both sound entries <code>MyGun.fire</code> and <code>MyGun.reload</code> (because both entries contain the sequence <code>MyGun</code>).
:; <code>invert_match</code> <[[bool]]>
|-
| <code>match_channel</code> || [[bool]] || false
| If set to true, sounds are only matched if they are in the same channel (e. g. <code>CHAN_STATIC</code>) as this sound entry.
|-
| <code>match_entity</code> || [[bool]] || false
| If set to true, sound are only matched if they are coming from the same entity as this sound entry.
|-
| <code>stop_this_entry</code> || [[bool]] || false
| Whether ''this'' entry (the one containing the operator stack where this property appears) should be stopped. If true, this property is sufficient to target a sound to stop. This property appears only to be usable in an <code>update_stack</code>, probably because when the code for <code>(pre)start_stack</code> is executed, the sound itself doesn't yet exist and thus can't reference itself at that moment.
|-
| <code>match_this_entry</code> || [[bool]] || false
| Unknown. Maybe an unused duplicate of <code>stop_this_entry</code>? When using {{cmd|snd_sos_show_operator_start|1}}, <code>match_this_entry</code> is listed, but <code>stop_this_entry</code> is not.
|-
| <code>stop_oldest</code> || [[bool]] || true
| Affects the choice of playing sounds if multiple are matching but not all are to be stopped. If set to true/false, stops oldest/youngest (the ones that were started the earliest/latest).
|-
| <code>invert_match</code> || [[bool]] || false
| If set to true, stops all currently playing sounds except the matching sounds.
|}
 
{| class=wikitable
! Output Name
! Type
! Description
|-
| <code>output_entries_matching</code> || [[float]]
| The number of entries that matched the defined entry when this operator has finished execution.<br>
{{note|This is an output, not an input. It cannot be set but instead be referenced in a subsequent operator using the value <code>"@''your_stop_entry_operator_name''.'''output_entries_matching'''"</code>.}}
|-
| <code>output_this_matches_index</code> || [[float]]
| Uncertain. It's an output so it'd be used in the same manner as <code>output_entries_matching</code>.
|}


==== sys_start_entry ====
==== sys_start_entry ====
: Plays another sound.
Plays another sound.
:; <code>input_execute</code> <[[float]]>
{| class=wikitable
:: If its value is greater than <code>0.0</code>, this operation will execute. Default value is <code>1.0</code>
| <code>input_execute</code> || [[float]]
:; <code>input_start</code> <[[float]]>
| If its value is greater than <code>0.0</code>, this operation will execute. Default value is <code>1.0</code>
:: If its value is greater than <code>0.0</code> the sound entry will start. Default value is <code>1.0</code>
|-
:;<code>entry_name</code> <[[string]]>
| <code>input_start</code> || [[float]]
:: The entry to play.
| If its value is greater than <code>0.0</code> the sound entry will start. Default value is <code>1.0</code>
:; <code>input_start_delay</code> <[[float]]>
|-
:: Adds a delay before an instance is played.
| <code>entry_name</code> || [[string]]
:; <code>input_maintain_seed</code> <[[float]]>
| The entry to play.
:: Greater than <code>0.0</code> will ensure that the <code>rndwave</code> selection is maintained.
|-
| <code>input_start_delay</code> || [[float]]
| Adds a delay before an instance is played.
|-
| <code>input_maintain_seed</code> || [[float]]
| Greater than <code>0.0</code> will ensure that the <code>rndwave</code> selection is maintained.
|}


==== sys_block_entries ====
==== sys_block_entries ====
: Prevents new sounds from playing.
Prevents new sounds from playing.
:; <code>input_duration</code>
 
:: How long to suppress sounds for.
{| class=wikitable
:; <code>input_active</code>
| <code>input_duration</code> ||
:: {{confirm|In addition to normal duration, suppress only when this value is true?}}
| How long to suppress sounds for.
:; <code>match_entry</code>
|-
:: Sound entry to suppress.
| <code>input_active</code> ||
:; <code>match_sound</code>
| {{Confirm|In addition to normal duration, suppress only when this value is true?}}
:: A raw WAV/MP3 filename to match. Possibly deprecated?
|-
:; <code>match_substring</code>
| <code>match_entry</code> ||
:: Whether <code>match_entry</code> can be part of a larger string (e.g. "MyGun" matches MyGun.fire, MyGun.reload).
| Sound entry to suppress.
:; <code>match_channel</code>
|-
:: Sound must have the same channel (e.g. CHAN_STATIC) as this one to match.
| <code>match_sound</code> ||
:; <code>match_entity</code>
| A raw [[WAV]]/[[MP3]]filename to match. Possibly deprecated?
:: Sound must be coming from the same entity as this one.
|-
| <code>match_substring</code> ||
| Whether <code>match_entry</code> can be part of a larger string (e.g. "MyGun" matches MyGun.fire, MyGun.reload).
|-
| <code>match_channel</code> ||
| Sound must have the same channel (e.g. CHAN_STATIC) as this one to match.
|-
| <code>match_entity</code> ||
| Sound must be coming from the same entity as this one.
|}


==== sys_output ====
==== sys_output ====
: Sends a value back to the sound system relating to the current entry.
Sends a value back to the sound system relating to the current entry.
:; <code>input_float</code>
{| class=wikitable
:: Takes a float value to send to the system.
| <code>input_float</code> ||
:; <code>input_vec3</code>
| Takes a float value to send to the system.
:: [[Vector]].
|-
:; <code>input_speakers</code>
| <code>input_vec3</code> ||
:: Takes an array of floats to send to the system, each to do with a certain speaker. Use only with the speakers output.
| [[Vector]].
:; <code>output</code>
|-
:: Says what value should be altered, for example:
| <code>input_speakers</code> ||
::; <code>speakers</code>
| Takes an array of floats to send to the system, each to do with a certain speaker. Use only with the speakers output.
::: Use in <code>update_stack</code>s only. Adjusts the volume of each speaker according to values given by <code>input_speakers</code>.
|-
::; <code>pitch</code>
| <code>output</code> || [[string]]
::: Use in <code>update_stack</code>s only. Adjusts the playback pitch of the sound to the value given with <code>input_float</code>.
| Says what value should be altered. Legal values are:
::; <code>dsp</code>
{| class=standard-table
::: Use in <code>update_stack</code>s only. Adjusts the DSP of the sound to the value given with <code>input_float</code>.
| <code>speakers</code>
::; <code>delay</code>
| Use in <code>update_stack</code>s only. Adjusts the volume of each speaker according to values given by <code>input_speakers</code>.
::: Use in <code>start_stack</code>s only. Waits for the number of seconds specified in <code>input_float</code> 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.
|-
::; <code>block_start</code>
| <code>pitch</code>
::: Use in <code>start_stack</code>s only. Prevents the sound from starting if the value given with <code>input_float</code> is non-zero.
| Use in <code>update_stack</code>s only. Adjusts the playback pitch of the sound to the value given with <code>input_float</code>.
::; <code>mixlayer_trigger</code>
|-
::: "Tell the mixlayer we're active" if the value given with <code>input_float</code> is non-zero.
| <code>dsp</code>
::: {{Note|A <code>mixlayer</code> allows you to modify properties (<code>volume</code>, <code>level</code>, <code>dsp</code>) of individual <code>mixgroups</code> within the active <code>soundmixer</code>. <code>mixlayers</code> can be found and created in <code>soundmixers.txt</code>.}}
| Use in <code>update_stack</code>s only. Adjusts the DSP of the sound to the value given with <code>input_float</code>.
::; <code>save_restore</code>
|-
::: {{confirm|Use in <code>update_stack</code>s only. Tells the system to save and restore the state of the sound if the value given with <code>input_float</code> is non-zero.}}
| <code>delay</code>
::; <code>stop_hold</code>
| Use in <code>start_stack</code>s only. Waits for the number of seconds specified in <code>input_float</code> 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.
::: Use in <code>update_stack</code>s only. {{confirm|Prevents the sound from stopping if the value given with <code>input_float</code> is non-zero.}}
|-
::; <code>facing</code>
| <code>block_start</code>
::: {{confirm|Make the sound play in a certain direction?}}
| Use in <code>start_stack</code>s only. Prevents the sound from starting if the value given with <code>input_float</code> is non-zero.
|-
| <code>mixlayer_trigger</code>
| "Tell the mixlayer we're active" if the value given with <code>input_float</code> is non-zero. {{Note|A <code>mixlayer</code> allows you to modify properties (<code>volume</code>, <code>level</code>, <code>dsp</code>) of individual <code>mixgroups</code> within the active <code>soundmixer</code>. <code>mixlayers</code> can be found and created in <code>soundmixers.txt</code>.}}
|-
| <code>save_restore</code>
| {{Confirm|Use in <code>update_stack</code>s only. Tells the system to save and restore the state of the sound if the value given with <code>input_float</code> is non-zero.}}
|-
| <code>stop_hold</code>
| Use in <code>update_stack</code>s only. {{Confirm|Prevents the sound from stopping if the value given with <code>input_float</code> is non-zero.}}
|-
| <code>facing</code>
| {{Confirm|Make the sound play in a certain direction?}}
|}
|}


==== sys_platform ====
==== sys_platform ====
: Tests what platform the engine is running on.
Tests what platform the engine is running on.
:; <code>pc</code>
{| class=wikitable
:; <code>x360</code>
| <code>pc</code> || [[bool]]
:; <code>ps3</code>
|rowspan=3| Should the operator return true if running on this platform?
:: Should the operator return true if running on this platform?
|-
| <code>x360</code> || [[bool]]
|-
| <code>ps3</code> || [[bool]]
|}
 
==== sys_mixlayer ====
==== sys_mixlayer ====
: Configures a <code>Mixlayer</code>. See <code>scripts\soundmixers.txt</code>
{{seealso|[[Soundmixer]], <code>scripts\soundmixers.txt</code>}}
:; <code>mixlayer</code> <[[string]]>
Configures a ''mixlayer'' which allows you to modify properties (<code>volume</code>, <code>level</code>, <code>dsp</code>) of individual <code>mixgroups</code> within the active <code>soundmixer</code>. Mixlayers can be found and created in <code>scripts\soundmixers.txt</code>.
:: The layer to alter.
 
:::{{Note|A <code>mixlayer</code> allows you to modify properties (<code>volume</code>, <code>level</code>, <code>dsp</code>) of individual <code>mixgroups</code> within the active <code>soundmixer</code>. <code>mixlayers</code> can be found and created in <code>soundmixers.txt</code>.}}
{| class=wikitable
:; <code>mixgroup</code> <[[string]]>
| <code>mixlayer</code> || [[string]]
:: The sound group within the layer to alter.
| The layer to alter.
:; <code>field</code> <[[string]]>
|-
:: Property of the group to alter.
| <code>mixgroup</code> || [[string]]
:; <code>input</code> <[[float]]>
| The sound group within the layer to alter.
|-
| <code>field</code> || [[string]]
| Property of the group to alter.
|-
| <code>input</code> || [[float]]
|
|}


=== Maths ===
=== Maths ===
''Generate or process numbers.''
''Generate or process numbers.''


Line 174: Line 244:


==== math_random ====
==== math_random ====
: Produces a random number.
Produces a random number.
:; <code>input_min</code>
{| class=wikitable
:; <code>input_max</code>
| <code>input_min</code> || [[float]]
:: Range of values to output.
| The lower bound for the random number.
:; <code>round_to_int</code>
|-
:: Set to <code>"true"</code> or <code>"false"</code>(default). This makes the output a whole number.
| <code>input_max</code> || [[float]]
| The upper bound for the random number.
|-
| <code>round_to_int</code> || [[bool]]
| Set to <code>"true"</code> or <code>"false"</code>(default). This makes the output a whole number.
|}
 
==== math_float ====
==== math_float ====
: Performs elementary maths operations with two values.
Performs elementary maths operations with two values.
:; <code>input1</code>
{| class=wikitable
:; <code>input2</code>
| <code>input1</code> || [[float]] || Operand A.
:: The two operands to use.
|-
:; <code>apply</code>
| <code>input2</code> || [[float]] || Operand B.
:: Specifies the operation to perform:
|-
::; <code>add</code>
| <code>apply</code> || [[string]] || Specifies the operation to perform:
::: A + B
{| class=standard-table
::; <code>sub</code>
| <code>add</code> || A &plus; B
::: A - B
|-
::; <code>mult</code>
| <code>sub</code> || A &minus; B
::: A * B
|-
::; <code>div</code>
| <code>mult</code> || A &times; B
::: A / B
|-
::; <code>mod</code>
| <code>div</code> || A &div; B. If B is &le; 0, returns 0.0.
::: Returns the remainder of A / B, or the modulus.
|-
 
| <code>pow</code>  || A<sup>B</sup>, raises A to the power of B.
::; <code>invert_scale</code>
|-
::: Unknown behaviour. Always performed on the output of cos(), and then used to multiply another value.
| <code>mod</code> || A % B, the [[w:Modulo|modulus]]. If B is &le; 0, returns 0.0.
 
|-
::; <code>min</code>
| <code>set</code> || A, ignores B.
::: Outputs the smallest of the two numbers.
|-
::; <code>max</code>
| <code>invert</code> || Returns 1 &minus; A, ignoring B.
::: Outputs the largest of the two numbers.
|-
 
| <code>invert_scale</code> || 1 + AB &minus; B.
::; <code>less_than</code>
|-
::: Checks if A < B, and outputs 1.0 or 0.0.
| <code>min</code> || Outputs the smallest of the two numbers.
::; <code>greater_than</code>
|-
::: Checks if A > B, and outputs 1.0 or 0.0.
| <code>max</code> || Outputs the largest of the two numbers.
::; <code>less_than_or_equal</code>
|-
::: Checks if A <= B, and outputs 1.0 or 0.0.
| <code>less_than</code> || If A &lt; B, outputs 1.0, else 0.0.
::; <code>greater_than_or_equal</code>
|-
::: Checks if A >= B, and outputs 1.0 or 0.0.
| <code>greater_than</code> || If A &gt; B, outputs 1.0, else 0.0.
::; <code>equals</code>
|-
::: If both are equal outputs 1.0, otherwise 0.0
| <code>less_than_or_equal</code> || If A &le; B, outputs 1.0, else 0.0.
|-
| <code>greater_than_or_equal</code> || If A &ge; B, outputs 1.0, else 0.0.
|-
| <code>equals</code> || If both are equal, outputs 1.0, else 0.0.{{inline note|name=float tolerance?}}
|-
| <code>not_equal</code> || If both are different, outputs 1.0, else 0.0.
|}
|}


==== math_float_accumulate12 ====
==== math_float_accumulate12 ====
: Does the same as <code>math_float</code>, but uses 12 inputs instead. All examples use <code>mult</code>.
Does the same as <code>math_float</code>, but uses 12 inputs instead. All examples use <code>mult</code>.
{| class=wikitable
|
<code>input1</code><br>
<code>input2</code><br>
<code>input3</code><br>
<code>input4</code><br>
<code>input5</code><br>
<code>input6</code><br>
<code>input7</code><br>
<code>input8</code><br>
<code>input9</code><br>
<code>input10</code><br>
<code>input11</code><br>
<code>input12</code>
| [[float]] || Operands 1-12.
|-
| <code>apply</code> || [[string]] || The operation to perform, see [[#math_float]]. For <code>mult</code> the output is <code>input1 * input2 * ... * input12</code>.
|}


==== math_func1 ====
==== math_func1 ====
: Executes various maths functions.
Executes an unary math function.
:; <code>input1</code>
{| class=wikitable
:: The argument to pass.
| <code>input1</code> || [[float]] || The argument to pass.
:; <code>function</code>
|-
:: Specifies the function to call:
| <code>function</code> || [[string]] || Specifies the function to call:
::; <code>none</code>
{| class=standard-table
::: Do nothing to the input.
| <code>none</code> || Do nothing to the input.
::; <code>round</code>
|-
::: Round to the nearest whole number.
| <code>round</code> || Round to the nearest whole number.
::; <code>floor</code>
|-
::: Round down to a whole number.
| <code>floor</code> || Round down to a whole number.
::; <code>ceil</code>
|-
::: Round up to a whole number.
| <code>ceil</code> || Round up to a whole number.
::; <code>fabs</code>
|-
::: Compute the absolute value of the input.
| <code>fabs</code> || Compute the absolute value of the input.
::; <code>sqrt</code>
|-
::: Computes the square root 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>exp</code> || Computes e raised to the power of the input.
::; <code>log</code>
|-
::: Computes the natural logarithm of the input.
| <code>log</code> || Computes the natural logarithm of the input.
::; <code>log10</code>
|-
::: Computes the logarithm base 10 of the input.
| <code>log10</code> || Computes the logarithm base 10 of the input.
::; <code>sin</code>
|-
::; <code>cos</code>
| <code>sin</code>, <code>cos</code>, <code>tan</code> || Computes the normal sin/cos/tan values. Angles are given in radians.
::; <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>asin</code>
|-
::; <code>acos</code>
| <code>sinh</code>, <code>cosh</code>, <code>tanh</code> || Computes the hyperbolic version of sin/cos/tan. Angles are given in radians.
::; <code>atan</code>
|}
::: Computes the inverse of sin/cos/tan. Angles are given in radians.
|-
::; <code>sinh</code>
| <code>normalize_trig</code> || [[bool]]
::; <code>cosh</code>
| If set to <code>"true"</code>, rescales the output from (&minus;1, +1) to (0, 1).
::; <code>tanh</code>
|}
::: Computes the hyperbolic version of sin/cos/tan. Angles are given in radians.
:; <code>normalise_trig</code>
:: If set to <code>"true"</code>, rescales the output from (-1, +1) to (0, 1).


==== math_logic_switch ====
==== math_logic_switch ====
: Selects one of two possible outputs.
Selects one of two possible outputs.
:; <code>input_switch</code>
{| class=wikitable
:: Chooses which of the other values is outputted.
| <code>input_switch</code> || [[float]] || 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>input1</code> || [[float]] || 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>.
| <code>input2</code> || [[float]] || The value to output if <code>input_switch</code> is <code>1</code>.
|}
 
==== math_speakers ====
Performs math operations with an array of (6?) volumes.
To use a single float value as an input array consisting only of that value, do <code>input2[*] 1.0</code> (which means <code>input2 = [1,1,...,1]</code>).
This operator has the output named <code>output</code> which can serve as an input for the <code>input_speakers</code> attribute of [[#sys_output]].
The operator [[#calc_spatialize_speakers]] has the output named <code>output</code> which can serve as an input for this operator.
{| class=wikitable
| <code>input1</code> || float array || [1,1,...,1] ||
|-
| <code>input2</code> || float array || [1,1,...,1] ||
|-
| <code>apply</code> || [[string]] || || The arithmetic operation to perform.
{| class=standard-table
| <code>mult</code> || <code>output[i] = input1[i] * input2[i]</code>
|-
| <code>max</code> || <code>output[i] = max(input1[i], input2[i])</code>
|}
|-
| <code>left_front</code><br><code>right_front</code><br><code>center</code><br><code>lfe</code><br><code>left_rear</code><br><code>right_rear</code> || [[float]] || 1.0
| Another input value for a specific volume of the array. Note that these values don't need to be specified if the operation is <code>mult</code> and <code>max</code> since the default value of 1.0 results in a constant change in both cases. {{confirm|If this is true, then the occurrence of this operator at {{operator stack|update_dialog_spatial|p2}} (operator "speakers_limit", second to last) is weird.}}
|}


==== math_curve_2d_4knot ====
==== math_curve_2d_4knot ====
: Multinode Remapper. Found in Insurgency(2014) and Day of Infamy ''sound_operator_stacks.txt''.
Multinode Remapper. Found in ''[[sound_operator_stacks.txt]]'' of {{Insurgency|2}} (2014) and {{Day of Infamy|2}}.
:; <code>curve_type</code>
:; <code>curve_type</code>
:: <code>step</code>, <code>linear</code>
:: <code>step</code>, <code>linear</code>
Line 285: Line 406:
==== math_remap_float ====
==== math_remap_float ====
: Remaps a value from one range to another (identically to [[math_remap]]).
: Remaps a value from one range to another (identically to [[math_remap]]).
:; <code>input</code>
:; <code>input</code> <[[float]]>
:: The value to remap.
:: The value to remap.
:; <code>input_min</code>
:; <code>input_min</code> <[[float]]>
:; <code>input_max</code>
:; <code>input_max</code> <[[float]]>
:: The smallest/largest value the input will be set to.
:: The smallest/largest value the input will be set to.
:; <code>input_map_min</code>
:; <code>input_map_min</code> <[[float]]>
:: When the input equals <code>input_min</code>, the output will be this value.
:: When the input equals <code>input_min</code>, the output will be this value.
:; <code>input_map_max</code>
:; <code>input_map_max</code> <[[float]]>
:: When the input equals <code>input_max</code>, the output will be this value.
:: When the input equals <code>input_max</code>, the output will be this value.
:; <code>default_to_max</code> <[[bool]]>
:; <code>clamp_range</code> <[[bool]]>


* math_delta
==== math_delta ====
:; <code>input</code> <[[float]]>


=== Getters ===
=== Getters ===
''Provide values from the engine.''
''Provide values from the engine.''


Line 316: Line 439:
==== get_entry_time ====
==== get_entry_time ====
: Collects information about the playing sound.  
: Collects information about the playing sound.  
:; <code>entry</code>
:: The entry to collect the information about
:; <code>output_entry_elapsed</code>
:; <code>output_entry_elapsed</code>
:: The time this sound has been playing.
:: The time this sound has been playing for.
{{warning|For looped sounds this won't reset when the sound starts a new loop, it will continue to count the time, resulting in it being bigger than the actual file length}}
:; <code>output_sound_elapsed</code>
:; <code>output_sound_elapsed</code>
:; <code>output_stop_elapsed</code>
:; <code>output_stop_elapsed</code>
:: -1 if playing, otherwise the time spent after being stopped.
:: -1 if playing, otherwise the time spent after being stopped.
:; <code>output_sound_duration</code>
:; <code>output_sound_duration</code>
:: The duration of the current sound. Zero during the start stack.
:: The total length of the sound file this stack is playing.
 
* Example operator stack to sync one track to another (including looping tracks), needs to be put in start_stacks in sound_operator_stacks.txt!
<source lang=php>
"synchronize_track" {
 
"catch_entry" { // Used to catch the entry we're syncing to
"operator" "get_entry_time"
}
 
 
"sound_offset" { // We have to account for the multiple loops that can happen
"operator" "math_float"
"apply" "mod"
"input1" "@catch_entry.output_entry_elapsed"  // Get the duration this sound has been playing for
"input2" "@catch_entry.output_sound_duration" // % it by the total duration of the file we're playing from
}
 
"invert_offset" { // We have to skip the duration, the delay paramater accepts negative values to do that
"operator" "math_float"
"apply" "mult"
"input1" "-1"
"input2" "@sound_offset.output"
}
 
"whoosh" { // Skip the seconds to sync
"operator" "sys_output"
"output" "delay"
"input_float" "@invert_offset.output"
}
//"printvar1" { // Optional to print the offset to the console that we have calculated
// "operator" "util_print_float"
// "input" "@invert_offset.output"
//}
}
</source>
 
*Example usage in a soundscript:
<source lang=php>
"my.music.basetrack" {...} // A soundscript that is running in the background that we'll be syncing TO
 
"my.music.overlay" { // We will be syncing this track to the upper one
// Of course you will have standard soundscript settings here
 
soundentry_version 2
operator_stacks {
    start_stack {
        import_stack synchronize_track
 
        catch_entry {
            entry "my.music.basetrack" // You have to set the name of the entry you're trying to synchronize to here
        }
    }
}
 
</source>


==== get_source_info ====
==== get_source_info ====
Line 328: Line 510:
:; <code>source</code>
:; <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.
:: 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>game_multi_origin</code> <[[bool]]>
:; <code>input_source_index</code> <[[float]]>
: ''Below are the data points output by this operator:'' ''@my_get_source_info_operator.output_position, etc..''
:; <code>output_entity_index</code>
:; <code>output_entity_index</code>
:: The index for this entity.
:: Returns the index of the source entity.
:; <code>output_position</code>
:; <code>output_position</code>
:: The position of the entity.
:: The position of the entity.
Line 342: Line 527:
:; <code>output_source_count</code>
:; <code>output_source_count</code>
:: The number of sounds (including this one) produced by the entity.
:: The number of sounds (including this one) produced by the entity.
 
==== game_view_info ====
==== game_view_info ====
: Collects a variety of game-specific information about the player for specialised uses.
: Collects a variety of game-specific information about the player for specialised uses.
:; <code>output_velocity_xy</code>
:; <code>input_source_index</code> <[[float]]>
:; <code>output_velocity_vector_z</code>
:; <code>output_position</code> <[[vector3]]>
:; <code>output_position_x</code>
:; <code>output_position_x</code> <[[float]]>
:; <code>output_position_y</code>
:; <code>output_position_y</code> <[[float]]>
:; <code>output_position_z</code>
:; <code>output_position_z</code> <[[float]]>
:: Returns the vector or X/Y/Z position for the provided <code>input_source_index</code>.
:; <code>output_angles</code> <[[vector3]]>
:; <code>output_velocity_vector</code> <[[vector3]]>
:; <code>output_velocity_vector_x</code> <[[float]]>
:; <code>output_velocity_vector_y</code> <[[float]]>
:; <code>output_velocity_vector_z</code> <[[float]]>
:; <code>output_velocity</code> <[[float]]>
:; <code>output_velocity_xy</code> <[[float]]>
:; <code>output_stop_elapsed</code>
:; <code>output_stop_elapsed</code>
==== game_entity_info ====
: Collects a variety of game-specific information about an entity for specialised uses.
:; <code>input_entity_index</code> <[[float]]>
:; <code>output_position</code> <[[vector3]]>
:; <code>output_position_x</code> <[[float]]>
:; <code>output_position_y</code> <[[float]]>
:; <code>output_position_z</code> <[[float]]>
:; <code>output_angles</code> <[[vector3]]>
:; <code>output_velocity_vector</code> <[[vector3]]>
:; <code>output_velocity_vector_x</code> <[[float]]>
:; <code>output_velocity_vector_y</code> <[[float]]>
:; <code>output_velocity_vector_z</code> <[[float]]>
:; <code>output_velocity</code> <[[float]]>
:; <code>output_velocity_xy</code> <[[float]]>


==== get_track_syncpoint ====
==== get_track_syncpoint ====
Line 391: Line 597:


==== get_soundmixer ====
==== get_soundmixer ====
: Outputs the active <code>soundmixer</code>
:: Outputs the active <code>soundmixer</code>
:; <code>mixgroup</code> <[[string]]>
:; <code>set_mixgroup_to_channel</code> <[[bool]]>


==== get_opvar_float ====
==== get_opvar_float ====
: Gets the value of an <code>opvar</code> created with the <code>set_opvar_float</code> operator.
:; <code>opvar</code> <[[string]]>


=== Setters ===
=== Setters ===
''Change values in the engine.''
==== set_convar ====
:: Set a engine varaiable
:; <code>convar</code> <[[string]]>
:; <code>input</code> <[[float]]>


''Change values in the engine.''
==== set_opvar_float ====
* set_convar
:: Create and set an <code>opvar</code> (operator varaible), to the value defined in <code>input</code>
* set_opvar_float
:; <code>opvar</code> <[[string]]>
* increment_opvar_float
:; <code>input</code> <[[float]]>


==== increment_opvar_float ====
:: Increments an <code>opvar</code> by the value of <code>input</code>.
:; <code>opvar</code> <[[string]]>
:; <code>input</code> <[[float]]>


=== Calculations ===
=== Calculations ===
''Calculate pre-set algorithms.''
''Calculate pre-set algorithms.''


Line 411: Line 630:
:; <code>input_position</code>
:; <code>input_position</code>
:: The sound source's position. Generally the output (<code>@get_info_op.output_position</code>) of a <code>get_source_info</code> operation.
:: The sound source's position. Generally the output (<code>@get_info_op.output_position</code>) of a <code>get_source_info</code> operation.
:; <code>in2D</code> <[[bool]]>
:: X/Y vectors only.
:; <code>force_not_player_sound</code> <[[bool]]>


==== calc_falloff ====
==== calc_falloff ====
Line 420: Line 642:


==== calc_distant_dsp ====
==== calc_distant_dsp ====
: Same setup as <code>calc_fallof</code>. Scales the <code>dsp</code> level defined in the sound's assigned <code>mixgroup</code> within the active <code>soundmixer</code> based on distance.
: Same setup as <code>calc_falloff</code>. Scales the <code>dsp</code> level defined in the sound's assigned <code>mixgroup</code> within the active <code>soundmixer</code> based on distance.
:; <code>input_distance</code>
:; <code>input_distance</code>
:: Sound source position. Generally the output of a <code>calc_source_distance</code> operation.
:: Sound source position. Generally the output of a <code>calc_source_distance</code> operation.
Line 428: Line 650:


==== calc_spatialize_speakers ====
==== calc_spatialize_speakers ====
:; <code>input_radius</code>
Calculates speaker volumes for a spatial sound, i. e. a sound that is emitted from some coordinates in the world as opposed to a sound that "plays everywhere". This operator has an output named <code>output</code> which is an array of float volumes suitable as an input for [[#math_speakers]].
:; <code>input_distance</code>
{| class=wikitable
:; <code>input_position</code>
| <code>input_position</code> || Vector || The location where the sound emitted from.
:; <code>input_rear_stereo_scale</code>
|-
| <code>input_radius</code> || [[float]] || The radius of a sphere around the input position. If the listener's distance to the sound source is...
* ... smaller than about half of the radius, the L/R volume levels are equal, no matter where the listener looks ("plays everywhere").
* ... larger than the radius, the sound is entirely directional (volume 0 on one side if looking 90° to the sound source).
* ... between the above two, the volume levels are blended appropriately.
|-
| <code>input_distance</code> || [[float]] || The distance from the <code>input_position</code> at which the listener currently is.
|-
| <code>input_rear_stereo_scale</code> || [[float]] || A factor to multiply the rear volumes with.{{confirm}}
|-
| <code>input_radius_min</code><br><code>input_radius_max</code> || [[float]] || Seen in CS:GO (e. g. {{operator stack|update_default|csgo}}) where all occurrences are set to the two values 23 and 24, and never combined with <code>input_radius</code>.
|}


==== calc_occlusion ====
==== calc_occlusion ====
Line 444: Line 677:
:: Generally the output (<code>@get_info_op.output_angles</code>) of a <code>get_source_info</code> operation.
:: Generally the output (<code>@get_info_op.output_angles</code>) of a <code>get_source_info</code> operation.


=== Other ===
=== Utilities ===


; <code>util_print_float</code>
==== util_print_float ====
: Displays a float in the console, along with the name of this operator.
: Displays a float in the console, along with the name of this operator.
:; <code>input</code>
:; <code>input</code>
:: The floating point value to show.
:: The floating point value to show.
* util_pos_vec8
 
* op_accumulate_ss_float
==== util_pos_vec8 ====
* iterate_merge_speakers
:; <code>input_index</code> <[[float]]>
* track_queue
:; <code>input_entry_count</code> <[[float]]>
* track_stop
:: Output the corresponding input position: a value of <code>1.0</code> output <code>input_position_1</code>.
* track_update
:; <code>input_position_0</code> <[[vector3]]>
:; <code>input_position_1</code> <[[vector3]]>
:; <code>input_position_2</code> <[[vector3]]>
:; <code>input_position_3</code> <[[vector3]]>
:; <code>input_position_4</code> <[[vector3]]>
:; <code>input_position_5</code> <[[vector3]]>
:; <code>input_position_6</code> <[[vector3]]>
:; <code>input_position_7</code> <[[vector3]]>
:; <code>output_position</code> <[[vector3]]>
:; <code>output_max_index</code> <[[float]]>
 
=== Other ===
 
==== track_queue ====
<code>prestart_stack</code>
:; <code>syncpoint_list</code> <[[string]]>
:{{Example|This code is in the<code>operator_stacks</code>code block within the Sound Entry of the containing sound script, not in<code>sound_operator_stacks.txt</code>}}
:<source>
"soundentry_operator_data"
{
"track_data"
{
"start_point" "0.353"
"end_point" "38"
"track_name" "main"
"priority" "1"
"priority_override" "true"
"syncpoints"
{
"syncpoints_1"
{
"1" "2.533"
"2" "5.066"
"3" "7.599"
"4" "10.132"
"5" "12.665"
"6" "15.198"
"7" "17.731"
"8" "20.264"
"9" "22.797"
"10" "25.33"
"11" "27.863"
"12" "30.396"
"13" "32.929"
"14" "35.462"
"15" "38"
}
}
}
}
"prestart_stack"
{
"sync_track_syncpoints"
{
"operator" "track_queue"
"syncpoint_list" "syncpoints_1"
}
}
</source>
 
==== track_update ====
:;<code>autoqueue_entry_at_end_point</code> <[[string]]>
:: Sound Entry to auto queue.
 
==== track_stop ====
{{todo}}
 
==== op_accumulate_ss_float ====
:;<code>input</code>
:;<code>iterate_operator</code>
:{{note|All four occurrences in [[sound_operator_stacks.txt/Portal 2]] are commented out:
:<source>// this calculates the loudest volume of the ss clients
// NOT NEEDED ALL SS OPS SELF-CONTAINGED
// "volume_acc_ss_max"
// {
// "operator" "op_accumulate_ss_float"
// "input" "volume_apply_occlusion.output"
// "iterate_operator" "occlusion"
// }
</source>
}}
 
==== iterate_merge_speakers ====
:;<code>input_max_iterations</code>
:;<code>iterate_operator</code>
:;<code>input</code>


[[Category:Sound System]]
[[Category:Sound System]]

Latest revision as of 18:06, 10 January 2025

English (en)Translate (Translate)

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

Finds currently playing sounds and stops the matching ones, optionally with a delay. Its essential properties are match_entry and/or match_sound to specify one or more sounds to stop.

Input Name Type Default Description
input_execute float 1.0 If set to a value smaller or equal to 0.0, no stopping is performed.
input_max_entries float 1.0 If set to x, stops as many matching sounds until there are less than x of them still playing. This usually does not include the new instance of the sound entry containing this operator: When used in a start_stack to stop instances of itself, setting this to n allows up to n+1 instances playing simultaneously.
Note.pngNote:The default value is 1, which stops all but one matches. Set to 0 to stop all matches.
input_stop_delay float 0.0 If some instance of a sound entry will be stopped, then with this delay in seconds.
match_entry string "" If this is not the empty string, matches only sounds that originate from a sound entry with this exact name (not case sensitive). If match_substring is set to true, matches all sounds whose sound entry name contains the specified string.
match_sound string "" If this is not the empty string, matches only sounds where the string of the path of their audio file equals the specified string (not case sensitive). For currently playing sounds, it's the path shown at the top right of the screen when snd_show 1 is set, which means that the string includes preceding sound characters as well as backslashes \ between directories (not forward slashes /).
If the property match_substring is true, all entries will be matched that contain this string in their path string.
match_substring bool false Alters the matches for both match_entry and match_sound. If set to false, those strings must be exactly equal. For example, if set to true, MyGun matches both sound entries MyGun.fire and MyGun.reload (because both entries contain the sequence MyGun).
match_channel bool false If set to true, sounds are only matched if they are in the same channel (e. g. CHAN_STATIC) as this sound entry.
match_entity bool false If set to true, sound are only matched if they are coming from the same entity as this sound entry.
stop_this_entry bool false Whether this entry (the one containing the operator stack where this property appears) should be stopped. If true, this property is sufficient to target a sound to stop. This property appears only to be usable in an update_stack, probably because when the code for (pre)start_stack is executed, the sound itself doesn't yet exist and thus can't reference itself at that moment.
match_this_entry bool false Unknown. Maybe an unused duplicate of stop_this_entry? When using snd_sos_show_operator_start 1, match_this_entry is listed, but stop_this_entry is not.
stop_oldest bool true Affects the choice of playing sounds if multiple are matching but not all are to be stopped. If set to true/false, stops oldest/youngest (the ones that were started the earliest/latest).
invert_match bool false If set to true, stops all currently playing sounds except the matching sounds.
Output Name Type Description
output_entries_matching float The number of entries that matched the defined entry when this operator has finished execution.
Note.pngNote:This is an output, not an input. It cannot be set but instead be referenced in a subsequent operator using the value "@your_stop_entry_operator_name.output_entries_matching".
output_this_matches_index float Uncertain. It's an output so it'd be used in the same manner as output_entries_matching.

sys_start_entry

Plays another sound.

input_execute float If its value is greater than 0.0, this operation will execute. Default value is 1.0
input_start float If its value is greater than 0.0 the sound entry will start. Default value is 1.0
entry_name string The entry to play.
input_start_delay float Adds a delay before an instance is played.
input_maintain_seed float Greater than 0.0 will ensure that the rndwave selection is maintained.

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/MP3filename 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_vec3 Vector.
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 string Says what value should be altered. Legal values are:
speakers Use in update_stacks only. Adjusts the volume of each speaker according to values given by input_speakers.
pitch Use in update_stacks only. Adjusts the playback pitch of the sound to the value given with input_float.
dsp Use in update_stacks only. Adjusts the DSP of the sound to the value given with input_float.
delay Use in start_stacks only. Waits for the number of seconds specified in input_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_stacks only. Prevents the sound from starting if the value given with input_float is non-zero.
mixlayer_trigger "Tell the mixlayer we're active" if the value given with input_float is non-zero.
Note.pngNote:A mixlayer allows you to modify properties (volume, level, dsp) of individual mixgroups within the active soundmixer. mixlayers can be found and created in soundmixers.txt.
save_restore
Confirm:Use in update_stacks only. Tells the system to save and restore the state of the sound if the value given with input_float is non-zero.
stop_hold Use in update_stacks 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 bool Should the operator return true if running on this platform?
x360 bool
ps3 bool

sys_mixlayer

See also:  Soundmixer, scripts\soundmixers.txt

Configures a mixlayer which allows you to modify properties (volume, level, dsp) of individual mixgroups within the active soundmixer. Mixlayers can be found and created in scripts\soundmixers.txt.

mixlayer string The layer to alter.
mixgroup string The sound group within the layer to alter.
field string Property of the group to alter.
input float

Maths

Generate or process numbers.

The result of these is stored in @name.output.

math_random

Produces a random number.

input_min float The lower bound for the random number.
input_max float The upper bound for the random number.
round_to_int bool Set to "true" or "false"(default). This makes the output a whole number.

math_float

Performs elementary maths operations with two values.

input1 float Operand A.
input2 float Operand B.
apply string Specifies the operation to perform:
add A + B
sub A − B
mult A × B
div A ÷ B. If B is ≤ 0, returns 0.0.
pow AB, raises A to the power of B.
mod A % B, the modulus. If B is ≤ 0, returns 0.0.
set A, ignores B.
invert Returns 1 − A, ignoring B.
invert_scale 1 + AB − B.
min Outputs the smallest of the two numbers.
max Outputs the largest of the two numbers.
less_than If A < B, outputs 1.0, else 0.0.
greater_than If A > B, outputs 1.0, else 0.0.
less_than_or_equal If A ≤ B, outputs 1.0, else 0.0.
greater_than_or_equal If A ≥ B, outputs 1.0, else 0.0.
equals If both are equal, outputs 1.0, else 0.0.[float tolerance?]
not_equal If both are different, outputs 1.0, else 0.0.

math_float_accumulate12

Does the same as math_float, but uses 12 inputs instead. All examples use mult.

input1
input2
input3
input4
input5
input6
input7
input8
input9
input10
input11
input12

float Operands 1-12.
apply string The operation to perform, see #math_float. For mult the output is input1 * input2 * ... * input12.

math_func1

Executes an unary math function.

input1 float The argument to pass.
function string Specifies the function to call:
none Do nothing to the input.
round Round to the nearest whole number.
floor Round down to a whole number.
ceil Round up to a 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.
log10 Computes the logarithm base 10 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.
sinh, cosh, tanh Computes the hyperbolic version of sin/cos/tan. Angles are given in radians.
normalize_trig bool If set to "true", rescales the output from (−1, +1) to (0, 1).

math_logic_switch

Selects one of two possible outputs.

input_switch float Chooses which of the other values is outputted.
input1 float The value to output if input_switch is 0.
input2 float The value to output if input_switch is 1.

math_speakers

Performs math operations with an array of (6?) volumes. To use a single float value as an input array consisting only of that value, do input2[*] 1.0 (which means input2 = [1,1,...,1]). This operator has the output named output which can serve as an input for the input_speakers attribute of #sys_output. The operator #calc_spatialize_speakers has the output named output which can serve as an input for this operator.

input1 float array [1,1,...,1]
input2 float array [1,1,...,1]
apply string The arithmetic operation to perform.
mult output[i] = input1[i] * input2[i]
max output[i] = max(input1[i], input2[i])
left_front
right_front
center
lfe
left_rear
right_rear
float 1.0 Another input value for a specific volume of the array. Note that these values don't need to be specified if the operation is mult and max since the default value of 1.0 results in a constant change in both cases.
Confirm:If this is true, then the occurrence of this operator at update_dialog_spatial (operator "speakers_limit", second to last) is weird.

math_curve_2d_4knot

Multinode Remapper. Found in sound_operator_stacks.txt of Insurgency Insurgency (2014) and Day of Infamy Day of Infamy.

curve_type
step, linear
input
Value that is compared to X: if input = X1 then ouput = Y1, if input = X2 then ouput = Y2, etc.
input_X1
input_Y1
input_X2
input_Y2
input_X3
input_Y3
input_X4
input_Y4

math_remap_float

Remaps a value from one range to another (identically to math_remap).
input <float>
The value to remap.
input_min <float>
input_max <float>
The smallest/largest value the input will be set to.
input_map_min <float>
When the input equals input_min, the output will be this value.
input_map_max <float>
When the input equals input_max, the output will be this value.
default_to_max <bool>
clamp_range <bool>

math_delta

input <float>

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_sys_time

Collects the host/client time.
output_client_time
output_host_time

get_entry_time

Collects information about the playing sound.
entry
The entry to collect the information about
output_entry_elapsed
The time this sound has been playing for.
Warning.pngWarning:For looped sounds this won't reset when the sound starts a new loop, it will continue to count the time, resulting in it being bigger than the actual file length
output_sound_elapsed
output_stop_elapsed
-1 if playing, otherwise the time spent after being stopped.
output_sound_duration
The total length of the sound file this stack is playing.
  • Example operator stack to sync one track to another (including looping tracks), needs to be put in start_stacks in sound_operator_stacks.txt!
"synchronize_track" {

		"catch_entry" { // Used to catch the entry we're syncing to
			"operator" "get_entry_time"
		}


		"sound_offset" { // We have to account for the multiple loops that can happen
			"operator" "math_float"
			"apply" "mod"
			"input1" "@catch_entry.output_entry_elapsed"  // Get the duration this sound has been playing for
			"input2" "@catch_entry.output_sound_duration" // % it by the total duration of the file we're playing from
		}

		"invert_offset" { // We have to skip the duration, the delay paramater accepts negative values to do that
			"operator" "math_float"
			"apply" "mult"
			"input1" "-1"
			"input2" "@sound_offset.output"
		}

		"whoosh" { // Skip the seconds to sync
			"operator" "sys_output"
			"output" "delay"
			"input_float" "@invert_offset.output"
		}
		
		//"printvar1" { // Optional to print the offset to the console that we have calculated
		//	"operator" "util_print_float"
		//	"input" "@invert_offset.output"
		//}
}
  • Example usage in a soundscript:
"my.music.basetrack" {...} // A soundscript that is running in the background that we'll be syncing TO

"my.music.overlay" { // We will be syncing this track to the upper one
// Of course you will have standard soundscript settings here

soundentry_version 2
operator_stacks {
    start_stack {
        import_stack synchronize_track

        catch_entry {
            entry "my.music.basetrack" // You have to set the name of the entry you're trying to synchronize to here
        }
    }
}

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.
game_multi_origin <bool>
input_source_index <float>
Below are the data points output by this operator: @my_get_source_info_operator.output_position, etc..
output_entity_index
Returns the index of the source 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.
input_source_index <float>
output_position <vector3>
output_position_x <float>
output_position_y <float>
output_position_z <float>
output_angles <vector3>
output_velocity_vector <vector3>
output_velocity_vector_x <float>
output_velocity_vector_y <float>
output_velocity_vector_z <float>
output_velocity <float>
output_velocity_xy <float>
output_stop_elapsed

game_entity_info

Collects a variety of game-specific information about an entity for specialised uses.
input_entity_index <float>
output_position <vector3>
output_position_x <float>
output_position_y <float>
output_position_z <float>
output_angles <vector3>
output_velocity_vector <vector3>
output_velocity_vector_x <float>
output_velocity_vector_y <float>
output_velocity_vector_z <float>
output_velocity <float>
output_velocity_xy <float>

get_track_syncpoint

Used to sync one sound entry to another.
syncpoint_list <string>
this_entry_syncpoints <bool>
input_min_time_to_next_sync <float>
input_max_time_to_next_sync <float>
match_entry <string>
Sound entry to match.
  • Example get_track_syncpoint
"start_delay_to_track_sync_point"
	{
		// the start sync point for the file we are syncing to
		"this_entry_syncpoints"
		{
			"operator" "get_track_syncpoint"
			"syncpoint_list" "syncpoints_1"
			"this_entry_syncpoints" "true"
		}
		"sync_track_syncpoints"
		{
			"operator" "get_track_syncpoint"
			"syncpoint_list" "syncpoints_1"
			"input_min_time_to_next_sync" 	"@this_entry_syncpoints.output_first_syncpoint"
			"input_max_time_to_next_sync" 	"1000"
			"match_entry" "DOTAMusic.BattleMusic"
		}
		// output our resulting delay value
		"delay_output"
		{
			"operator" "sys_output"
			"input_float" "@sync_track_syncpoints.output_time_to_next_syncpoint"
			"output" "delay"
		}
	}

get_soundmixer

Outputs the active soundmixer
mixgroup <string>
set_mixgroup_to_channel <bool>

get_opvar_float

Gets the value of an opvar created with the set_opvar_float operator.
opvar <string>

Setters

Change values in the engine.

set_convar

Set a engine varaiable
convar <string>
input <float>

set_opvar_float

Create and set an opvar (operator varaible), to the value defined in input
opvar <string>
input <float>

increment_opvar_float

Increments an opvar by the value of input.
opvar <string>
input <float>

Calculations

Calculate pre-set algorithms.

calc_source_distance

Calculates the distance from this sound source (emitter/entity) to the listener.
input_position
The sound source's position. Generally the output (@get_info_op.output_position) of a get_source_info operation.
in2D <bool>
X/Y vectors only.
force_not_player_sound <bool>

calc_falloff

Calculates the falloff of a sound based on the distance from the sound source (emitter/entity) to the listener and the multiplied output of the sound entries soundlevel and the level property value of its assigned mixgroup within the active soundmixer.
input_distance
Sound source position. Generally the output of a calc_source_distance operation.
input_level
Sound source's level/attenuation. Generally the output of a multiplication operation of the sound entries soundlevel and the mixgroup level within the active soundmixer.

calc_distant_dsp

Same setup as calc_falloff. Scales the dsp level defined in the sound's assigned mixgroup within the active soundmixer based on distance.
input_distance
Sound source position. Generally the output of a calc_source_distance operation.
input_level
Sound source's level/attenuation. Generally the output of a multiplication operation of the sound entries soundlevel and the mixgroup level within the active soundmixer.
Note.pngNote:The output of this operation is then multipled by the dsp property value (@get_soundmixer_op.output_dsp) of the assigned mixgroup within the active soundmixer, with the output then being input to a sys_output dsp operation.

calc_spatialize_speakers

Calculates speaker volumes for a spatial sound, i. e. a sound that is emitted from some coordinates in the world as opposed to a sound that "plays everywhere". This operator has an output named output which is an array of float volumes suitable as an input for #math_speakers.

input_position Vector The location where the sound emitted from.
input_radius float The radius of a sphere around the input position. If the listener's distance to the sound source is...
  • ... smaller than about half of the radius, the L/R volume levels are equal, no matter where the listener looks ("plays everywhere").
  • ... larger than the radius, the sound is entirely directional (volume 0 on one side if looking 90° to the sound source).
  • ... between the above two, the volume levels are blended appropriately.
input_distance float The distance from the input_position at which the listener currently is.
input_rear_stereo_scale float A factor to multiply the rear volumes with.[confirm]
input_radius_min
input_radius_max
float Seen in CS:GO (e. g. update_default) where all occurrences are set to the two values 23 and 24, and never combined with input_radius.

calc_occlusion

Performs audio occlusion calculations.
input_trace_interval
input_scalar
input_position
Generally the output (@get_info_op.output_position) of a get_source_info operation.

calc_angles_facing

input_angles
Generally the output (@get_info_op.output_angles) of a get_source_info operation.

Utilities

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

input_index <float>
input_entry_count <float>
Output the corresponding input position: a value of 1.0 output input_position_1.
input_position_0 <vector3>
input_position_1 <vector3>
input_position_2 <vector3>
input_position_3 <vector3>
input_position_4 <vector3>
input_position_5 <vector3>
input_position_6 <vector3>
input_position_7 <vector3>
output_position <vector3>
output_max_index <float>

Other

track_queue

prestart_stack

syncpoint_list <string>
PlacementTip.pngExample:This code is in theoperator_stackscode block within the Sound Entry of the containing sound script, not insound_operator_stacks.txt
"soundentry_operator_data"
{
	"track_data"
	{
		"start_point" "0.353"
		"end_point" "38"
		"track_name" "main"
		"priority" "1"
		"priority_override" "true"
		"syncpoints"
		{
			"syncpoints_1"
			{
				"1"	"2.533"
				"2" "5.066"
				"3"	"7.599"
				"4" "10.132"
				"5" "12.665"
				"6" "15.198"
				"7" "17.731"
				"8" "20.264"
				"9" "22.797"
				"10" "25.33"
				"11" "27.863"
				"12" "30.396"
				"13" "32.929"
				"14" "35.462"
				"15" "38"
			}
		}
	}
}
"prestart_stack"
{
	"sync_track_syncpoints"
	{
		"operator" "track_queue"
		"syncpoint_list" "syncpoints_1"
	}
}

track_update

autoqueue_entry_at_end_point <string>
Sound Entry to auto queue.

track_stop

[Todo]

op_accumulate_ss_float

input
iterate_operator
Note.pngNote:All four occurrences in sound_operator_stacks.txt/Portal 2 are commented out:
// this calculates the loudest volume of the ss clients
// NOT NEEDED ALL SS OPS SELF-CONTAINGED
// "volume_acc_ss_max"
// {
	// "operator" "op_accumulate_ss_float"
	// "input" "volume_apply_occlusion.output"
	// "iterate_operator" "occlusion"
// }

iterate_merge_speakers

input_max_iterations
iterate_operator
input