Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
318b53c
Rename TFL references to be more generic and neutral
LuminarLight Oct 17, 2026
92e928b
Significantly improve handling and safety of custom music
LuminarLight Oct 17, 2026
7b86400
Remove TFL hints code and unused and leftover custom music functions
LuminarLight Oct 17, 2026
5cf3ef5
Add support for custom music flava, add example in lltest2
LuminarLight Oct 17, 2026
5c06761
Use correct include
LuminarLight Oct 17, 2026
bb13ea4
Update readme
LuminarLight Oct 17, 2026
5c743b1
Put custom music c++ code into its own files
LuminarLight Oct 17, 2026
502510f
Play custom music in debug menu, just like base game music
LuminarLight Oct 17, 2026
7e45a1f
Make lltest2 ambients have same trans and bsphere because one is used…
LuminarLight Oct 17, 2026
75446fb
Adjust credits regarding custom music
LuminarLight Oct 17, 2026
7ce3660
Remove many unnecessary comments
LuminarLight Oct 17, 2026
88b53c3
Remove more comments
LuminarLight Oct 17, 2026
e55f994
Add volume_tweak feature (like TWEAKVAL.MUS)
LuminarLight Oct 17, 2026
19ab2d3
Adjust readme a bit
LuminarLight Oct 17, 2026
c4797a7
Reduce max flava-table-row s in flava-table from 64 to 32 (was 20 in …
LuminarLight Oct 18, 2026
3617143
Fix type consistency
LuminarLight Oct 18, 2026
422bd02
Significantly simplify the custom music flow
LuminarLight Oct 18, 2026
64e7393
Guard against negative gain values of layers
LuminarLight Oct 18, 2026
d81ee6e
Allow music files with two neighbouring dots in the name just in case…
LuminarLight Oct 18, 2026
551a440
Make custom music init engine safer
LuminarLight Oct 18, 2026
6f4ce93
End our lltest musicset with newline
LuminarLight Oct 18, 2026
15a6ee5
Remove more unnecessary comments
LuminarLight Oct 18, 2026
cce509a
Remove another unnecessary comment
LuminarLight Oct 18, 2026
147bd32
Fix fake layer syncs
LuminarLight Oct 18, 2026
16897ae
Add a zoomer to lltest2
LuminarLight Oct 18, 2026
305705f
Adjust readme
LuminarLight Oct 20, 2026
6b96c47
Reorder art groups in lltest2 jsonc
LuminarLight Oct 20, 2026
23e8969
Reduce comments a bit in GOAL
LuminarLight Oct 20, 2026
74a628c
Reduce comments a bit more in custom music cpp
LuminarLight Oct 20, 2026
0931448
Merge branch 'master' into ll/add-flava-support-for-custom-music
LuminarLight Oct 21, 2026
9a453ef
Try to fix linux gcc build
LuminarLight Oct 21, 2026
dc12e2c
Add ogg support
LuminarLight Oct 21, 2026
9fc33bc
Try to make linux gcc build finish in time.....
LuminarLight Oct 21, 2026
aaccad8
Fix MacOS build
LuminarLight Oct 21, 2026
f2c36d9
Adjust coments bit more
LuminarLight Oct 21, 2026
c29c5b4
Mention myself in custom music credits
LuminarLight Oct 22, 2026
11ed282
Update readme final time maybe
LuminarLight Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 69 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ As I said, this is my personal mod base. Feel free to use it, but expect limited

The mod base contains a level called `lltest2`. You may find some examples of the mod base's features implemented in it. Please do not change anything about the level, otherwise you will run into merge conflicts. In the future I might add more and more examples into it, to show people what are currently possible.

## Using This Mod Base

You are welcome to use this mod base, or parts of it, for your own mods. But I have a few requests.

Please be respectful regarding crediting the people behind the features/changes. I tried to mention if a change was developed by someone else. If I missed anyone, please let me know and I will try to correct it.

Also, if you manage to find a way to improve one of the modbase's features, please let me know. It would be nice to add such improvements to this modbase.

## Mod Base's Custom Changes

### Load All SBKs
Expand All @@ -18,13 +26,69 @@ This change is currently only implemented for TPL. It wouldn't make too much sen

### Custom Music

I borrowed the custom music system from 'The Forgotten Lands' mod, and made some changes to it. As far as I know, the base of that whole system was initially created by Zed, and then it was greatly expanded by Hat-Kid. Please let me know if this is inaccurate and I will adjust this section.
Later the other modbase found a worthy replacement for SFML, called 'miniaudio', and they let me look at their changes. I implemented these on our side.
You can play music files of flac, mp3, wav, or ogg format. Put the files in `custom_assets/jak1/custom_sound/music/`. After that, there are two main ways to play your custom music:
- Set the `custom-music` property in your level's `level-load-info` to your music's name (symbol).
- Place a music ambient (sphere) in your level, and set its `custom-music` lump to your music's name (symbol). In this case you don't want to set the `music` lump at all - custom music shouldn't be combined with base game music.

When a music change is triggered, the old one fades out, and after that the new one fades in (each takes 1 second) - this is similar to how base game music fades in/out.
I have also expanded the 3D debug text of music ambients, now it shows the following additional properties: `music`, `custom-music`, `flava`.

#### Variants (flava)

You can optionally configure your custom music to support variants (flava). To do this, place a `[music name].musicset.jsonc` file next to your audio files. Here is an example:

```jsonc
{
"variant_fade_ms": 1500, // how long a variant change takes, in ms (default 1500)
"stream": false, // true = stream the files instead of loading them into memory (default false)
"volume_tweak": 1.0, // multiplies the volume of the whole set (default 1.0), like TWEAKVAL.MUS does for base game music
"layers": { "base": "coolmusic.flac", "drums": "coolmusic+drums.flac" },
// the variant number is the index; variant 0 plays for every event that isn't mapped
"variants": [
{ "base": 1.0 },
{ "base": 1.0, "drums": 1.0 }
]
}
```

- All layers should be exactly the same length. If this is not the case, you will get a warning in the console. MP3 can't guarantee exact lengths, because encoders can add padding, so we recommend using the other formats.
- Layers don't need to share the same format. For example, one layer can be ogg and another one can be flac.
- A recommended naming convention for layer files is `name+layer.extension`. The `+` character is reserved for layers, so a music name can't contain it.
- Layer paths are relative to the music folder. Absolute paths and `..` are not allowed.
- A layer missing from a variant is silent (it gets a default gain of 0.0). This makes configuration easier if you have a lot of layers.
- Without a `musicset` file, the music plays as a single file, whose name (without extension) must match the music name (for example `coolmusic.flac` for `coolmusic`).
- Setting `stream` to false loads all layers into memory, instead of streaming them from the storage. This can use a lot of memory, but avoids storage latency. If layers drift apart, they are re-aligned automatically, but only when not streamed.
- If you trigger a variant ID that doesn't exist in the music set, it will fall back to 0 and print a warning (only once per music set).

The `variants` are made to work with the base game's flava system. A flava is an event that is active while Jak is somewhere, or doing something - it can be set by music ambients (literally spheres you place in levels), or set directly in code. Each music track has its own interpretation for events, in its own row in `goal_src/jak1/engine/sound/gsound.gc`, at the same place where it is done for base game music:

I implemented a way to use custom music for music ambients. To use it, just use the `custom-music` lump instead of the `music` lump in your music ambient. Also expanded the 3D debug text that is drawn when you are displaying music ambients.
```lisp
(flava-table-add coolmusic (corner 1)) ;; while the corner event is active, coolmusic plays variant 1
```

I made some other minor changes to the custom music system for now, the GOAL side is quite different now but the c++ side is mostly unchanged. For the future I want to make its namings more generic/neutral (so they don't refer to The Forgotten Lands in the name). I also want to implement a way to have music variants/flavors, and I already have a clear vision for it, but I will have to rewrite a lot of code on the c++ side. And while there, I will probably do a general cleanup of that code as well.
Also, for now, the TFL hints system is not reimplemented, since we switched to miniaudio. It is planned though.
Events can be set by a music ambient with a `flava` lump:

```jsonc
"flava": ["enum-uint32", "(music-flava corner)"],
// Priority is optional, default is 10.0. The highest wins; in case of a tie, the one evaluated last wins
"priority": ["float", 20.0]
```

Or in the code with `(set-setting! 'sound-flava #f [priority] (music-flava corner))`.

Different music tracks can map the same event to different variants, so reusing event names is okay. You can add new events to the `music-flava` enum in `goal_src/jak1/engine/sound/gsound-h.gc` (and don't forget to make the same change in `decompiler/config/jak1/all-types.gc`).

You can also map existing events to custom music - for example, the `racer` event is active while Jak is on a Zoomer (its priority is 30.0):

```lisp
(flava-table-add othermusic (racer 1))
```

You can see the music `lltest`, implemented/used in the `lltest2` level of this mod base, if you want to see a working example.

#### Credits

The first working custom music system was created by Zed, then it was greatly expanded by Hat-Kid. Later, barg and Zed ported it from SFML to miniaudio in the other modbase, and let me use their changes. What we have in this modbase today is Luminar Light's significantly reworked and improved version of all of those prior implementations - this is the first implementation that supports variants/flava. The C++ side of this rework was heavily AI-assisted. Please let me know if any of this is inaccurate and I will adjust this section.

---

Expand Down Expand Up @@ -103,8 +167,6 @@ I am happy if anyone finds this useful. But I have a request: If you learn more

## Future Plans

- Implement flavor/variant support for custom music.
- Make the TFL hints system work again.
- Clean up GitHub Actions.
- Understand more about the navmesh system (node, route).
- Show how to add new `battle` actors, also show the part that needs to be done through code. I have already touched the battle system in the past. I should clear things up and implement an example.
Expand Down Expand Up @@ -148,8 +210,6 @@ git merge vanilla/master --allow-unrelated-histories --no-commit

As I said, this is my personal mod base. Support is limited/nonexistent. Still, I imagine there may be people who will find it useful. I am happy if that happens. And you can still reach out to me if you want, but I won't be able to help with basic stuff.

I tried to mention if a change was developed by someone else. If I missed anyone, please let me know and I will correct it. On the other hand, if you use this mod base or parts of it, please be respectful regarding crediting the people behind the features/changes.

*~~Luminar Light*

---
Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions custom_assets/jak1/custom_sound/music/lltest.musicset.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"variant_fade_ms": 1500,
"stream": false,
"volume_tweak": 1.0,
"layers": {
"base": "lltest.flac",
"beats": "lltest+beats.flac"
},
"variants": [
{
"base": 1.0,
"beats": 0.0
},
{
"base": 1.0,
"beats": 1.0
}
]
}
10 changes: 10 additions & 0 deletions custom_assets/jak1/levels/lltest2/lltest2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
"citb-bunny.o"
"hopper.o"
"lurkerpuppy.o"
"target-racer-h.o"
"racer-part.o"
"racer.o"
"target-racer.o"
"racer-states.o"
"collide-reaction-racer.o"
"eichar-racer+0-ag.go"
"tpage-1119.go"
"blocking-plane.o"
"tpage-398.go"
"tpage-400.go"
"tpage-399.go"
Expand All @@ -21,6 +30,7 @@
"water-anim-training-ag.go"
"water-anim-sunken-dark-eco-ag.go"
"plat-ag.go"
"racer-ag.go"
"driller-lurker-ag.go"
"mother-spider-ag.go"
"baby-spider-ag.go"
Expand Down
30 changes: 27 additions & 3 deletions custom_assets/jak1/levels/lltest2/lltest2.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

"base_id": 40000,

"art_groups": ["plat-ag", "water-anim-training-ag", "water-anim-sunken-dark-eco-ag", "driller-lurker-ag", "mother-spider-ag", "baby-spider-ag", "spider-egg-ag", "babak-ag", "quicksandlurker-ag", "hopper-ag", "lurkerpuppy-ag", "citb-bunny-ag"],
"art_groups": ["babak-ag", "baby-spider-ag", "citb-bunny-ag", "driller-lurker-ag",
"hopper-ag", "lurkerpuppy-ag", "mother-spider-ag", "plat-ag", "quicksandlurker-ag",
"racer-ag", "spider-egg-ag", "water-anim-sunken-dark-eco-ag", "water-anim-training-ag"],

"custom_models": [],

"textures": [
["village1-vis-alpha"]
["village1-vis-alpha"],
["zoomerhud"]
],

"tex_remap": "village1",
Expand All @@ -27,13 +30,23 @@

"ambients": [
{
"trans": [0.0, 602.0, -110.0, 10.0],
"trans": [0.0, 602.0, -110.0, 15.0],
"bsphere": [0.0, 602.0, -110.0, 15.0],
"lump": {
"name": "lltest2-ambient-1",
"type": "'music",
"custom-music": "'lltest-sphere"
}
},
{
"trans": [-77.27, 600.00, -91.17, 25.0],
"bsphere": [-77.27, 600.00, -91.17, 25.0],
"lump": {
"name": "lltest2-ambient-2",
"type": "'music",
"custom-music": "'lltest",
"flava": ["enum-uint32", "(music-flava corner)"]
}
}
],

Expand Down Expand Up @@ -286,6 +299,17 @@
}
},

{
"trans": [0.0, 557.1, 295.7],
"etype": "racer",
"game_task": 0,
"quat" : [0, 0, 0, 1],
"bsphere": [0.0, 557.1, 295.7, 10],
"lump": {
"name": "lltest2-racer-1"
}
},

{ // Shoutout to Hat Kid for the water stuff.
"trans": [0.0, 602.0, -110.0], // translation
"etype": "water-anim", // actor type // TEST ACTOR //
Expand Down
15 changes: 8 additions & 7 deletions decompiler/config/jak1/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@
(finalboss-middle 47)
(finalboss-end 48)
(default 49)
(corner 50)
)

;; - Enums
Expand Down Expand Up @@ -16671,21 +16672,21 @@

(deftype flava-table-row (structure)
((music symbol :offset-assert 0)
(flava uint8 50 :offset-assert 4)
(flava uint8 256 :offset-assert 4) ;; modbase: was 50
)
:allow-misaligned
:method-count-assert 9
:size-assert #x36
:flag-assert #x900000036
:size-assert #x104
:flag-assert #x900000104
)

(deftype flava-table (basic)
((row flava-table-row 20 :inline :offset-assert 4)
(count int32 :offset-assert 1284)
((row flava-table-row 32 :inline :offset-assert 4) ;; modbase: was 20
(count int32 :offset-assert 8708)
)
:method-count-assert 9
:size-assert #x508
:flag-assert #x900000508
:size-assert #x2208
:flag-assert #x900002208
)

;; - Functions
Expand Down
7 changes: 7 additions & 0 deletions game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ set(RUNTIME_SOURCE
kernel/common/klink.cpp
kernel/common/klisten.cpp
kernel/common/kmachine.cpp
kernel/common/custom_music.cpp
kernel/common/miniaudio_impl.c
kernel/common/kmalloc.cpp
kernel/common/kmemcard.cpp
kernel/common/kprint.cpp
Expand Down Expand Up @@ -384,6 +386,11 @@ set(RUNTIME_SOURCE
tools/subtitle_editor/subtitle_editor.cpp
)

# GCC takes too long to compile miniaudio at -O3, timing out CI
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(kernel/common/miniaudio_impl.c PROPERTIES COMPILE_OPTIONS "-O1")
endif()

add_subdirectory(sound)

# we build the runtime as a static library.
Expand Down
Loading
Loading