├── README.md
├── SimpleSound
├── README.md
├── audiodirectory
│ ├── custom_sounds.awc
│ ├── custom_sounds.awc.xml
│ └── custom_sounds
│ │ ├── sound01.wav
│ │ └── sound02.wav
├── client.lua
├── data
│ ├── audioexample_sounds.dat54.rel
│ └── audioexample_sounds.dat54.rel.xml
└── fxmanifest.lua
└── weaponAudio
├── README.md
├── client.lua
├── dlccustomweaponsounds
├── custom_weapon_sounds.awc
├── custom_weapon_sounds.awc.xml
└── custom_weapon_sounds
│ └── x16_mainfire.wav
├── fxmanifest.lua
└── x16pistol
├── x16pistol_game.dat151.rel
├── x16pistol_game.dat151.rel.xml
├── x16pistol_sounds.dat54.rel
└── x16pistol_sounds.dat54.rel.xml
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # What is this?
3 | This is a collection of examples on how to make *"custom native audio"*. This will allow you to benefit from the audio engine in GTA without the use of NUI. I would highly suggest you take a look at this [GitHub repository](https://github.com/Monkeypolice188/Monkys-Audio-Research) to see what is possible (a LOT).
4 |
5 | And a big thank you to everyone talking about it in the [CodeWalker discord](https://discord.gg/codewalker) and especially everyone I had personal contact with that led me to the small thing that I was missing to make this work
6 |
7 | ### Contributors ✨
8 |
14 |
15 | ## [SimpleSound](SimpleSound)
16 | Simple sound entries as the name implies, are used for simple sounds. However it is broadly used as this is the beginning of every sound entry. Before a `.wav` sound is ready to be used, it needs to be registered first as a `SimpleSound`. Luckely for us it only takes one extra step to use these sounds and that is adding the sounds to a `SoundSet`. This is the perfect alternative for people using simple sound effects from resources like [Interact-Sound](https://github.com/plunkettscott/interact-sound) and [xSound](https://github.com/Xogy/xsound).
17 |
18 | ## [Weapon audio](weaponAudio)
19 | Using the `WeaponAudioItem` entry inside of a `dat151` file, we can modify the `PlayerFire` entry. This will be streamed to every client thus everyone hears the same sound. This way we don't have to rely on the client downloading the appropiate files to modify their sounds. Furthermore we can finally adapt the sounds of addon weapons instead of relying on existing WeaponAudioItems.
--------------------------------------------------------------------------------
/SimpleSound/README.md:
--------------------------------------------------------------------------------
1 |
2 | ### To begin with we are going to create a `.awc` container which will hold all the audio files.
3 |
4 | 1. Gather all the sounds you want to use. This is obviously personal preference and this can be done though https://www.youtube.com/ or whatever. Preferably these sounds should be in the `Waveform Audio File Format | .wav for short`. But these are hard to come by. Which is no problem as we can do this ourselves.
5 |
6 | 2. Once you got everything you want, you will need to convert these sounds to `.wav` files. This can be done however you want but I personally use Sony Vegas as that is what I am comfortable with. As long if you do what is written below there should be no problem whatever software you use.
7 | - Simply drag & drop one of the sounds in your software of choice, and render it back into a `.wav` with a sample rate (Hz) of 32.000, bit depth of 8 or 16 and it has to be in mono, not stereo. The format will be `PCM` or `ADPCM`. Do this for every sound you have[^1][^4][^5].
8 |
9 | 3. Now put all of these sound files in a folder. For the sake of this tutorial call this folder `custom_sounds`.
10 |
11 | 4. Using the template file included that is called `custom_sounds.awc.xml`, I want you to edit this file in whatever IDE you use. I already included 2 example sounds in the template.
12 | - Firstly change both the `` and `` entries. `` is going to be the filename of your converted sound files which you put in the folder `custom_sounds`. `` however can be anything you want but it is simply easier to keep this the same or rather similar.
13 | - `` will be `PCM` since we converted the sounds into this format.
14 | - `` will be `` because we used the 32kHz sample rate. The `` value however needs to be calculated by you by doing `audio duration * sample rate`. If you don't know the exact duration I would highly advise you use [Audacity](https://www.audacityteam.org/) for this part. Once Audacity is installed simply drag the sound into it, double click to select the whole clip. The samples value will be displayed below[^2]. Fill this in inside the `.xml` file.
15 |
16 | - Now I'm no audio head, but there are other entries included which you can play with to prepare your sounds before use. But I would keep `` at minus 1 because otherwise your sound will keep looping if this is set at 0 for example. Have fun and play around with these entries.
17 |
18 | 5. Once you have added all of your sound entries you can go ahead and open CodeWalker[^3]. Make sure both your folder containing the sounds and the `.xml` file you just edited are on the same level so that wherever you put them you can see them both. Enable edit mode and right click to Import XML. Find your XML file and press done. Now you should have a working `.awc` container with all the sounds included. Upon importing, if you get `"Object reference not set to an instance of an object"`, it can be for a multitude of reasons such as:
19 | - Incorrect folder/file structure
20 | - .awc.xml file name does not match folder name
21 | - Soundname cannot be found in folder (either missing or typo in either filename or awc file entry)
22 | - The sound is stero (>=2 channels) instead of Mono
23 | - The sound is not PCM or ADPCM
24 | - Invalid XML entry (e.g. missing information, such as samples, name etc.)
25 |
26 |
27 | ### Now onto making the corresponding `.dat54` file
28 |
29 | 1. Using the included template `audioexample_sounds.dat54.rel.xml`. We are going to make 2 `SimpleSounds` which will be usable through a `soundset`. You can however include as many simple sounds as you want of course.
30 |
31 | 2. Editing a `.dat54.rel.xml` file
32 |
33 | - First we have the `` entry. This name will be used later on in the file and can be named however you want. But again for simplicity just name it the same way you did your sound name. Rockstar however uses some internal naming scheme depending on which type of sound you are adding. `MultitrackSound` for example end with `_mt`.
34 |
35 | - ``. Here you can change a lot of attributes of the sound. Most flags have already been discovered and I would highly suggest you look at this [GitHub repository](https://github.com/Monkeypolice188/Monkys-Audio-Research/blob/main/sounds.dat54/Dat54Sound%20Header) to get an idea of which flags are available. In the template I am using `0x00008004`. This can be broken down to `0x00000004` for Volume and `0x00008000` to change the category (Category is very important if we want to use a sound in a `soundset`!!!. Please keep this at scripted)
36 |
37 | - And finally the `` and ``. These two are to locate the actual sound inside of your `.awc` container. `` will start from wherever your resource that is streaming the sounds is located. Following the example below as structure with the resource named `resourceAudio`. The entry in `` should be `audiodirectory/custom_sounds`. `` should be the name you gave the sound in your `.awc.xml` file (The `` entry not ``!).
38 | ```bash
39 | resourceAudio
40 | │
41 | ├── audiodirectory
42 | │ └── custom_sounds.awc
43 | ├── data
44 | │ └── audioexample_sounds.dat54.rel
45 | ├── fxmanifest.lua
46 | ├── client.lua
47 | ```
48 |
49 | - Once you have created all of your SimpleSounds you want. You will need to insert them all into a `SoundSet` to actually use them in game. The 2 example sounds are already inside of the template. You simply need to add your sounds. The `` entry here can be whatever you want. You can add more sounds inside of the `` entry. `` will be the name of the sound that you call inside of scripts. `` will be what you named your `SimpleSound` from before in the same file.
50 |
51 | 3. Now you are once again ready to simply Import XML inside of CodeWalker and you should have a valid `.dat54.rel` file.
52 |
53 | Following the same folder structure as mentioned above and a simple code snippet, you should now have working "native" sounds 😊. Thanks to everyone making this possible and spreading information on this topic. And I highly suggest you use [this repo](https://github.com/Monkeypolice188/Monkys-Audio-Research) and join the [CodeWalker discord](https://discord.gg/codewalker) to find more information about the topic
54 |
55 | [^1]: https://media.discordapp.net/attachments/844240881283366962/1136305015754076210/V3R14LYUIVgpZw.png
56 |
57 | [^2]: https://cdn.discordapp.com/attachments/803679370156965920/1136335474986860696/6knzX5lqLcjX4B.png
58 |
59 | [^3]: As of writing, I used `CodeWalker30_dev44`
60 |
61 | [^4]: A sample rate of 32kHz mostly gets used for simple sound effects. 44.1 and 48kHz gets used for songs. And 24kHz gets used for speech interactions.
62 |
63 | [^5]: There seems to be some kind of limit on the size of the `.wav` and even the `.awc`. Limit is unknown(?) but keep it under ~1.5MB. Knowing that the base game files exceed this there *should* be a way to counteract this "limit".
64 |
--------------------------------------------------------------------------------
/SimpleSound/audiodirectory/custom_sounds.awc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChatDisabled/nativeAudio/dfdaa953994dc71d87c24fd272dda0fba74c796e/SimpleSound/audiodirectory/custom_sounds.awc
--------------------------------------------------------------------------------
/SimpleSound/audiodirectory/custom_sounds.awc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | sound01
8 | sound01.wav
9 |
10 |
11 | peak
12 |
13 |
14 | data
15 |
16 |
17 | format
18 | ADPCM
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | sound02
33 | sound02.wav
34 |
35 |
36 | peak
37 |
38 |
39 | data
40 |
41 |
42 | format
43 | ADPCM
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/SimpleSound/audiodirectory/custom_sounds/sound01.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChatDisabled/nativeAudio/dfdaa953994dc71d87c24fd272dda0fba74c796e/SimpleSound/audiodirectory/custom_sounds/sound01.wav
--------------------------------------------------------------------------------
/SimpleSound/audiodirectory/custom_sounds/sound02.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChatDisabled/nativeAudio/dfdaa953994dc71d87c24fd272dda0fba74c796e/SimpleSound/audiodirectory/custom_sounds/sound02.wav
--------------------------------------------------------------------------------
/SimpleSound/client.lua:
--------------------------------------------------------------------------------
1 |
2 | -- RequestScriptAudioBank will be used to load the .awc container that holds all the sounds. Follow the folder structure starting from the resource audiodirectory/custom_sounds
3 |
4 | -- The audioRef will be `special_soundset` because we called our soundset that
5 | -- You can use any sound that you put inside your soundset.
6 |
7 | RegisterCommand('testsound', function (source, args, raw)
8 | while not RequestScriptAudioBank('audiodirectory/custom_sounds', false) do Wait(0) end
9 | print('Audio bank loaded')
10 | local soundId = GetSoundId()
11 | PlaySoundFrontend(soundId, 'wow', 'special_soundset', true)
12 | ReleaseSoundId(soundId)
13 | Wait(2000)
14 | local soundId2 = GetSoundId()
15 | PlaySoundFrontend(soundId2, 'error', 'special_soundset', true)
16 | ReleaseSoundId(soundId2)
17 | ReleaseNamedScriptAudioBank('audiodirectory/custom_sounds')
18 | end, false)
19 |
--------------------------------------------------------------------------------
/SimpleSound/data/audioexample_sounds.dat54.rel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChatDisabled/nativeAudio/dfdaa953994dc71d87c24fd272dda0fba74c796e/SimpleSound/data/audioexample_sounds.dat54.rel
--------------------------------------------------------------------------------
/SimpleSound/data/audioexample_sounds.dat54.rel.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | audiodirectory\custom_sounds
6 |
7 |
8 |
9 |
10 | sound_01_sp
11 |
12 |
13 |
14 | scripted
15 |
16 | audiodirectory/custom_sounds
17 | sound01
18 |
19 |
20 |
21 | sound_02_sp
22 |
23 |
24 |
25 | scripted
26 |
27 | audiodirectory/custom_sounds
28 | sound02
29 |
30 |
31 |
32 |
33 |
34 | special_soundset
35 |
36 |
37 |
38 |
39 |
40 | wow
41 | sound_01_sp
42 |
43 |
44 | error
45 | sound_02_sp
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/SimpleSound/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | fx_version 'cerulean'
2 | game 'gta5'
3 |
4 | client_script 'client.lua'
5 |
6 | files {
7 | 'data/audioexample_sounds.dat54.rel',
8 | 'audiodirectory/custom_sounds.awc',
9 | }
10 |
11 | data_file 'AUDIO_WAVEPACK' 'audiodirectory'
12 | data_file 'AUDIO_SOUNDDATA' 'data/audioexample_sounds.dat'
--------------------------------------------------------------------------------
/weaponAudio/README.md:
--------------------------------------------------------------------------------
1 | > [!WARNING]
2 | > I would highly suggest you learn on how to make SimpleSounds first.
3 |
4 | The example provided here is the x16 pistol for which I used [this post](https://www.gta5-mods.com) on https://www.gta5-mods.com. Since this is a pistol, I used the sns pistol as base template. Therefore the other sounds like reloading and such will be based on that. I have only replaced the `PlayerFire` entry which is the main firing sound.
5 |
6 | If you just want to test this out. Run this resource (everything withing `weaponAudio`) and edit your weapon.meta of choice where you want to apply the sound. Find the `