Difference between revisions of "Hpl2:HPL2/Tutorials/CustomSounds"

From Frictional Wiki
Jump to navigation Jump to search
(Upload from wiki)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
= How to add Custom Sounds? =
+
= Adding custom sounds =
 +
== Preparing the sounds ==
  
 +
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.
  
Hello! Stepper321 (And friends) here, i'm gonna teach you how to add custom sounds!
+
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.
  
 +
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}
  
== Having the sounds ==
+
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.
  
 +
== Managing sound files ==
  
First you'll need a sound-editting program, you can do this by using [http://www.erightsoft.com/S6Kg1.html|SUPER]] (Recommended) [http://audacity.sourceforge.net/download/|Audacity] or [[http://www.sonycreativesoftware.com/download/trials/vegaspro Sony Vegas] (Not free)
+
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.
  
 +
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}
  
The sounds need to be in '''.ogg ''' format, If your soundfiles are formatted as '''.MP3''', '''.WAV''' or anything else, you may use one of the said above programs to convert your soundfile of choice to an '''''.'' ogg''' file format.
+
Place the tutorial.ogg file in the created (sub)folder.
  
 +
== Creating the sound entity file ==
  
For my example, my script file is called '''tutorial.txt''', and the sound is '''door.ogg'''.
+
The behaviour of the sound in the game is determined by a "sound entity" file. These files have a '''.snt''' extension.
  
== Placing the sounds in the right folder ==
+
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch.
  
 +
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}
  
You need to go to your custom story folder and create a new folder called: “sounds” and in that folder an: “extrasounds” folder. In there you place the tutorial.ogg file.<br />
+
Alternatively, you can do the following:
('''You can name it what ever you want.''')
 
== Making the sound work in Amnesia ==
 
  
Create a '''.txt''' file and name it the name of your sound's Script, open it with any Text Editor you use. I use [http://wiki.frictionalgames.com/hpl2/third_party_tools/text/notepad?s[]=notepad Notepad++]. I named my file <u>'''tutorial'''</u>'''.txt'''.
+
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.
 +
 
 +
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}
  
 
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is <u>'''door'''</u>'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.
 
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is <u>'''door'''</u>'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.
<syntaxhighlight lang="">
+
<syntaxhighlight lang="xml">
 
<SOUNDENTITY>
 
<SOUNDENTITY>
 
  <SOUNDS>
 
  <SOUNDS>
Line 37: Line 44:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Maybe you're asking, what the hell is all of this? I will explain :
+
Format explanation:
 
 
<'''SOUNDENTITY''' > is the start of the sound file to know what it will play, it can only have one. (Like the extra_english file you have normally in your Custom Story :))
 
 
 
<'''SOUNDS''' > is the sound what it will play
 
 
 
<'''Main''' > is the main sound it will play, i don't know if there exist other categories for that. But use it
 
 
 
<'''Sound File''' =" ''YourFileName''.ogg" /> is the sound file it will play, if you add multiple sound files, it will play the sounds randomly.
 
 
 
<'''PROPERTIES''' > Are all the options you may use to decide how the sound will behave in-game, like '''MinDistance''' is what distance you have to be in to hear it, since 1 is the players exact size, You will hear the sound perfectly if you stand on it. Beyond that, you will be able to hear the sound until the distance specified in '''MaxDistance''', I don't know exactly but I think that "1" distance is a meter, excuse me if i'm wrong :). (Probably an inch, a person 1 meter in width? '''Needs to be confirmed''')
 
 
 
Well thats it! You now created your very own sound! Use it with PlaySoundAtEntity(syntax) in your custom level-script; (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to know what syntax to use)
 
 
 
= Custom Music =
 
 
 
 
 
Custom musics are exactly the same steps as the custom sounds. But you won't need an .snt file created as long as you do it with PlayMusic(syntax); or at the credits.
 
 
 
  
Prepare your .ogg file with the same steps as the Custom Sounds.
+
<'''SOUNDENTITY'''> is the start marker of the sound file
  
 +
<'''SOUNDS'''> indicates the sound list
  
Create a new folder called "music" and in the 'music' folder one that's called "extramusic" put it in there. ('''Again, you may name it whatevas you want''')
+
<'''Main'''> is the list of sounds the file will play. It is unsure if other categories exist.
  
 +
<'''Sound File'''="''YourFileName''.ogg" /> is the way to add a file to the sound. Adding multiple files will play them randomly.
  
Now use '''PlayMusic''' (Syntex); (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to know what syntax to use)
+
<'''PROPERTIES'''> Are all the options you may use to decide how the sound will behave in-game. Most important ones are:
 +
*'''MinDistance''' is what distance you have to be in to hear it, since 1 is the players exact size, You will hear the sound perfectly if you stand on it. The sound will be heard with less and less volume until getting further than the distance specified in '''MaxDistance'''.
 +
*If you have multiple sounds, changing the '''Random="0"''' parameter to the number of sound files might be needed.{{confirm}}
 +
*'''Loop="False"''' - Make sure to change this to true if your sound should loop.
 +
*'''Use3D="false"''' - Setting this as true will make the sound fade if the player rotates right and left from the sound origin. Using false will only use the distance to fade the sound.{{confirm}}
 +
{{warning|Stereo files will never work with this! The file needs to be mixed into a mono track to use this parameter. Also keep in minds stereo doesn't fade with distance.}}
  
 +
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with <code>PlaySoundAtEntity();</code> in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).
  
Now maybe you're thinking that you could use this '''like''' a sound effect? Well ; [http://i0.kym-cdn.com/photos/images/original/000/262/501/be7.gif NOPE]. Music has only two "layers" (Priorities). 0 and 1. I.E: only'''one can play at once.'''
+
= Adding custom music =
  
 +
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with <code>PlayMusic();</code> or at the credits, but you won't be able to use <code>PlaySoundAtEntity();</code> with this file.
  
If 1 '''is ''<u>not__ '' specified''', track 0 will play. If 1'''''__is</u> '' specified''', ONLY "1" will play.<br />
+
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.
(You can use that to suddenly or smoothly fade-stop a track in it's place, initiate a different track for your scene, and than resume the previous track. Pretty much what happens when a grunt chases you; only that is automatic!)
 
  
 +
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use <code>PlayMusic();</code>.
  
<br />
+
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.
Send suggestions for tutorials to my forum account by Personal Messaging me at this link: [http://www.frictionalgames.com/forum/user-17976.html Stepper321's personal forum account].<br />
 
<font 8px:normal/Arial;;inherit;;inherit >(Everything is in good will, Stepper, your guide was quite incoherent. Cheers for the initiative ~Yer wiki-friends.)</font>
 

Revision as of 19:09, 2 November 2020

Adding custom sounds

Preparing the sounds

First you'll need a sound-editting program; Audacity is a common choice - it is free and will suit most needs.

The sounds need to be in .ogg format. If your sound files are formatted as .MP3, .WAV or anything else, you need to use one your audio editing software of choice to convert your sound file to an .ogg file format. In Audacity, you just need to drag the file into the program and then export as .ogg.

Icon tip.png Tip: It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.

If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.

Managing sound files

In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but sounds would probably be the best.

Icon tip.png Tip: If your mod has a lot of custom sounds, make sure to organise them into subfolders!

Place the tutorial.ogg file in the created (sub)folder.

Creating the sound entity file

The behaviour of the sound in the game is determined by a "sound entity" file. These files have a .snt extension.

For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch.

Icon tip.png Tip: If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.

Alternatively, you can do the following:

Create a .txt file and name it what you want (same as the .ogg file is common), open it with any text editor you use. Notepad++ is recommended. When you finish editing the file, change the extension to the correct one. I named my file tutorial.snt.

Icon tip.png Tip: Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.

In the file, you can edit quite a few things, and among them is..Adding your sound-file into the script! And since my sound file is door.ogg, It shall go to the MAIN section. Random soundfiles will be covered later on.

<SOUNDENTITY>
 <SOUNDS>
   <Main>
      <Sound File="door.ogg" />
   	</Main>
   </SOUNDS>
   <PROPERTIES Volume="5" MinDistance="1" MaxDistance="50" Random="0" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="false" Blockable="False" BlockVolumeMul="0.7" Priority="5" />
</SOUNDENTITY>

Format explanation:

<SOUNDENTITY> is the start marker of the sound file

<SOUNDS> indicates the sound list

<Main> is the list of sounds the file will play. It is unsure if other categories exist.

<Sound File="YourFileName.ogg" /> is the way to add a file to the sound. Adding multiple files will play them randomly.

<PROPERTIES> Are all the options you may use to decide how the sound will behave in-game. Most important ones are:

  • MinDistance is what distance you have to be in to hear it, since 1 is the players exact size, You will hear the sound perfectly if you stand on it. The sound will be heard with less and less volume until getting further than the distance specified in MaxDistance.
  • If you have multiple sounds, changing the Random="0" parameter to the number of sound files might be needed.[Confirm]
  • Loop="False" - Make sure to change this to true if your sound should loop.
  • Use3D="false" - Setting this as true will make the sound fade if the player rotates right and left from the sound origin. Using false will only use the distance to fade the sound.[Confirm]
Alert icon.png Warning: Stereo files will never work with this! The file needs to be mixed into a mono track to use this parameter. Also keep in minds stereo doesn't fade with distance.

Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with PlaySoundAtEntity(); in your level script (check Engine scripts for details).

Adding custom music

Custom music only needs to be a file in the .ogg format. It won't need an .snt file to be played with PlayMusic(); or at the credits, but you won't be able to use PlaySoundAtEntity(); with this file.

Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. music. Put the .ogg file there.

See Engine scripts to learn how to use PlayMusic();.

Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.