Mod: 音频

此页面的内容需要被翻译。

你可以帮助我们来翻译此页面。

模组页面

This page explains how to: **Extract** the default audio files; how to **Replace** the default audio files with your own sounds; and how to **Add** additional custom audio files.

## Extracting and Replacing the existing audio

The `.wav` audio files are compressed in 20+ `.bank` files within the folder `Steam\steamapps\common\Noita\data\audio\Desktop\`.

1. Download & extract "Fmod bank tools.zip" (discord link)
2. Find any bank you'd like to edit (e.g. `event_cues.bank`) and copy paste it into the bank folder of the zip you extracted.
3. Run the `Fmod Bank Tools.exe` and set your `Bank Source Folder` to the path of the bank folder (full path, `C:/.../bank`) and the `Wav Destination Folder` to the path of the wav folder (full path again). Both of these folders should be in the extracted zip folder.
4. Click the Extract button in the tool to get all of the audio files in the bank.
	* Now you can create music using the game sounds!
5. Replace (or add) any .wav files you want, edit the `bankname.txt` in the wav folder to have the correct names of your sounds and then in the `Fmod Bank Tools.exe` click Rebuild. If you get any errors, you can simply Ok through them until its finished.
6. Get in-game and test (keep in mind this is mainly for replacing rather than adding, as you can do that with FMOD Studio instead with much more features).

**NOTE: Because this replaces the bank, you cannot have multiple sound replacing mods!**

## Creating custom audio for Noita

Noita uses FMOD Studio as its sound effects engine, using version 2.01.05. The basic principle is defining FMOD "bank" files consisting of all the sound effects and attaching individual events for each sound. These events are then referenced in the XML / Lua, which play the correct sound effect.

Check out the following directories to get started:

* `Noita/tools_modding/noita-fmod-project/`
* `Noita/mods/example/`

### Setup

1. Make sure you have the noita-fmod-project folder in your Noita directory.
2. Install FMOD Studio version 2.01.05 from the official FMOD website.

### FMOD

1. Open **noita-mods.fspro** in FMOD Studio, you should see an **snd\_mod** folder which contains an example `create` event. In Noita, there are many different events, but for now, keep in mind `create` and `loop`, as those are the most common.
2. Clicking the `create` event in **snd\_mod** will show you the example sound `worm_attack_bite_01` which is in Async mode, has Randomization Automation for its pitch, and has Distance and lowpass parameters which can allow for effects in-game such as volume fading.
3. Noita also has many Routing Groups which add effects to your audio such as reverb and equalization, to access these you'll need to go to the `Window` options and then `Mixer`, where you can move your sounds into their respective groups, such as `game_sfx` which houses `snd_mod/create`, this group is what you'll likely use the most.
4. Once you've decided to make a sound in an event, you'll need to add it to a Bank so that Noita can use it as part of its assets. To do this, simply right click the event, go to `Assign to Bank` and click the bank you're going to use (preferably something besides Master Bank).
5. After all of the above, you can finally Build your FMOD project by going to `File` options and doing `Build`.
6. We're not done yet, as Noita still doesn't know how to access the events in your bank, so you'll need to go back to `File` options, and then to `Export GUIDs`. This will be what you load in your init.lua script so that Noita has the references to your bank's sounds.

### Noita

1. Go into `noita-fmod-project/Build` and copy and paste the **GUIDs.txt** into your mod's directory.
2. Go into `noita-fmod-project/Build/Desktop` and copy and paste the `bankname`.bank file (ignore Master Bank) you created in FMOD into your mod's directory.
3. Open your mod's **init.lua** file and add
```
ModRegisterAudioEventMappings("mods/modname/directory/to/GUIDs.txt")

```
with the path to your GUIDs.txt file.
4. Open any xml files which you want to add your sounds to and add the respective `AudioComponent` or `AudioLoopComponent` depending on the type of event you created in FMOD. An example `AudioComponent` for a projectile might look like this:
```
<AudioComponent
 file="mods/modname/directory/to/bankname.snd" <!-- .bank is replaced with .snd -->
 event_root="foldername/eventname" <!-- in fmod you created an event \*folder\* which had either a \*create\* or \*loop\* event -->
 set_latest_event_position="1"
></AudioComponent>

```
5. Get in-game and experience success!