<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FSOMA%2FScripting%2FAudio_Helper</id>
	<title>HPL3/SOMA/Scripting/Audio Helper - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FSOMA%2FScripting%2FAudio_Helper"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Audio_Helper&amp;action=history"/>
	<updated>2026-10-04T04:30:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Audio_Helper&amp;diff=7212&amp;oldid=prev</id>
		<title>TiMan: Add a sourced SOMA guide with explanations and stock-script examples.</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Audio_Helper&amp;diff=7212&amp;oldid=prev"/>
		<updated>2026-10-02T12:06:34Z</updated>

		<summary type="html">&lt;p&gt;Add a sourced SOMA guide with explanations and stock-script examples.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{shortPageTitle}}&lt;br /&gt;
&lt;br /&gt;
The Audio helper file in SOMA is &amp;lt;code&amp;gt;script/helpers/helper_audio.hps&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Audio helpers create world-positioned sounds, play GUI sounds, control music and start named voice subjects. Sound_CreateAtEntity creates a sound at an entity or the player; Sound_Play is for an existing placed or previously created sound.&lt;br /&gt;
&lt;br /&gt;
== Before you start ==&lt;br /&gt;
# Open the map script inside your own mod. Keep its generated includes, &amp;lt;code&amp;gt;cScrMap : iScrMap&amp;lt;/code&amp;gt; class and callback structure. See [[HPL3/SOMA/Getting Started/Add Your First Script|Add your first script]] if you have not edited a map script yet.&lt;br /&gt;
# Add the helper include shown below alongside the script’s other includes.&lt;br /&gt;
# Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.&lt;br /&gt;
&lt;br /&gt;
== Follow the stock example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;helpers/helper_audio.hps&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound_CreateAtEntity ===&lt;br /&gt;
Create and play a sound (.snt) file at the position of an entity or player.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundName&amp;lt;/code&amp;gt; || name of the sound that is used when you like to, for example, stop it.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundFile&amp;lt;/code&amp;gt; || name of the FMOD event or .snt sound file to play. FMOD always needs to be full path ie &amp;quot;project/event_group(s)/event&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntity&amp;lt;/code&amp;gt; || name of the entity to play the sound at, can also be &amp;quot;player&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afFadeTime&amp;lt;/code&amp;gt; || fade in the sound during this many seconds, 0 = no fade.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;abSaveSound&amp;lt;/code&amp;gt; || if the sound should be saved, ie if sound loops and the sound should play on exit and enter of the level.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afTargetVolume&amp;lt;/code&amp;gt; || the volume (0.0 - 1.0) the sound should be played at. Defaults to 1.0f.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;maps/chapter05/05_02_ARK_inside/05_02_ARK_inside.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;Sound_CreateAtEntity&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Sound_CreateAtEntity(&amp;quot;ExitCaveSweet&amp;quot;, &amp;quot;05_02/SFX/exit_cave_sweet&amp;quot;, &amp;quot;Player&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;ExitCaveSweet&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundFile&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;05_02/SFX/exit_cave_sweet&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntity&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;Player&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
=== Sound_Play ===&lt;br /&gt;
Play a sound that exists in the level editor, attached to an entity, or previously created that&lt;br /&gt;
has been stopped and now should be played again.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundName&amp;lt;/code&amp;gt; || name of the sounds that you would like to play. Wildcard(s) * are supported.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afFadeTime&amp;lt;/code&amp;gt; || fade in the sound during this many seconds, 0 = no fade.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;abResetVolMul&amp;lt;/code&amp;gt; || reset the FadeVolumeMul set when using Sound_Fade.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;maps/_e3/_e3_01_01/_e3_01_01.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;Sound_Play&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Sound_Play(&amp;quot;sparks_area_1&amp;quot;, 1.0f);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSoundName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;sparks_area_1&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afFadeTime&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;1.0f&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
=== Voice_Play ===&lt;br /&gt;
Starts playing a voice&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asSubject&amp;lt;/code&amp;gt; || The name of the subject to play.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;alSpecificLineIdx&amp;lt;/code&amp;gt; || if 0 or higher then a specific line index will be played. Set as -1 to play as stated in the data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asCallback&amp;lt;/code&amp;gt; || called when subject is done playing. Syntax: void Func(const tString&amp;amp;in asScene, const tString&amp;amp;in asSubject)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;alPrio&amp;lt;/code&amp;gt; || The priority of the voice, if higher than the currently playing, the current gets stopped and replaced, else this voice is not played.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Check your change ==&lt;br /&gt;
Save the script and restart the map in development mode with &amp;lt;code&amp;gt;F5&amp;lt;/code&amp;gt;. If the script fails, open &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; and use '''Show Error List''' or '''Show HPL Log'''. See [[HPL3/SOMA/Getting Started/Test Debug and Continue|the development loop]] for the launch and debugging steps.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[HPL3/SOMA/Scripting|SOMA scripting]]&lt;br /&gt;
* [[HPL3/SOMA/Scripting/Scripting Api|SOMA scripting API]]&lt;br /&gt;
&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>TiMan</name></author>
		
	</entry>
</feed>