You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/client/audio.md
+74-47Lines changed: 74 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: "Audio"
3
3
description: "Sound system in LCE."
4
4
---
5
5
6
-
LCE's audio system is built on the Miles Sound System (MSS) library, wrapped in a two-class hierarchy. `ConsoleSoundEngine` defines the platform interface, and `SoundEngine` provides the shared implementation. The system handles positional 3D audio, background music streaming, and UI sound effects.
6
+
LCE's audio system is wrapped in a two-class hierarchy. `ConsoleSoundEngine` defines the platform interface, and `SoundEngine` provides the shared implementation. The system handles positional 3D audio, background music streaming, and UI sound effects.
7
+
8
+
The original console builds used the **Miles Sound System** (MSS) library from RAD Game Tools. LCEMP has replaced Miles with **miniaudio** (`miniaudio.h`), a single-header C audio library. The API surface is the same (the `ConsoleSoundEngine` interface hasn't changed), but the backend is different. Xbox 360 used native XAudio instead of Miles.
7
9
8
10
## Architecture
9
11
@@ -48,31 +50,28 @@ The sound name tables (`wchSoundNames` and `wchUISoundNames`) map sound type enu
48
50
49
51
### SoundEngine (implementation)
50
52
51
-
`SoundEngine` extends `ConsoleSoundEngine` with the Miles Sound System backend:
53
+
`SoundEngine` extends `ConsoleSoundEngine`. In LCEMP, it uses miniaudio as the backend:
52
54
53
55
```cpp
54
56
class SoundEngine : public ConsoleSoundEngine {
55
57
static const int MAX_SAME_SOUNDS_PLAYING = 8;
56
58
57
-
HMSOUNDBANK m_hBank; // sound bank handle
58
-
HDIGDRIVER m_hDriver; // audio driver handle
59
-
HSTREAM m_hStream; // streaming handle
59
+
ma_engine m_maEngine; // miniaudio engine
60
+
bool m_maEngineInitialized;
61
+
62
+
ma_sound m_activeSounds[MA_MAX_SOUNDS]; // active sound pool (64 slots)
63
+
bool m_activeSoundUsed[MA_MAX_SOUNDS];
64
+
65
+
ma_sound m_musicStream; // current streaming music
66
+
bool m_musicStreamActive;
60
67
};
61
68
```
62
69
63
-
## Miles Sound System integration
70
+
`MA_MAX_SOUNDS` is 64, the maximum number of sounds that can play at once. The engine manages this pool with `findFreeSoundSlot()` (finds a free slot) and `cleanupFinishedSounds()` (reclaims slots from finished sounds).
64
71
65
-
The Miles Sound System headers are included per platform:
66
-
67
-
| Platform | Header path |
68
-
|---|---|
69
-
| PS3 |`PS3/Miles/include/mss.h`|
70
-
| PS Vita |`PSVITA/Miles/include/mss.h`|
71
-
| Xbox One (Durango) |`Durango/Miles/include/mss.h`|
72
-
| PS4 (Orbis) |`Orbis/Miles/include/mss.h`|
73
-
| Windows 64 |`Windows64/Miles/include/mss.h`|
74
-
75
-
Xbox 360 uses the native XAudio system instead of Miles.
72
+
:::note
73
+
The original console builds used the Miles Sound System (MSS). The MSS headers were included per platform (`PS3/Miles/include/mss.h`, `PSVITA/Miles/include/mss.h`, `Durango/Miles/include/mss.h`, `Orbis/Miles/include/mss.h`, `Windows64/Miles/include/mss.h`). Xbox 360 used native XAudio instead of Miles. LCEMP replaced all of this with miniaudio.
When `SoundEngine::play()` fires, it builds a Miles event name like `"Minecraft/mob.zombie"` from the dot-separated string and enqueues it to the event system. `ConvertSoundPathToName()` handles the conversion from dots to the slash-separated event paths that Miles expects.
95
+
When `SoundEngine::play()` fires, it converts the dot-separated sound name to a file path using `ConvertSoundPathToName()` and plays it through the audio backend. In the original Miles builds, this produced event names like `"Minecraft/mob.zombie"`. In LCEMP's miniaudio backend, it resolves to audio files on disk.
97
96
98
97
## 3D audio
99
98
@@ -158,7 +157,7 @@ The `fSoundClipDist` parameter (default 16 blocks) controls how far away a sound
158
157
159
158
## Sound attenuation
160
159
161
-
All 3D sounds use a custom linear falloff function instead of the default Miles rolloff:
160
+
All 3D sounds use a custom linear falloff function instead of the default engine rolloff. In the original Miles builds, this was registered as a callback. LCEMP implements the same logic in miniaudio:
162
161
163
162
```cpp
164
163
F32 AILCALLBACK custom_falloff_function(
@@ -207,44 +206,67 @@ Ambient, hurt, death, and step sounds for every mob:
207
206
|`eSoundType_MOB_WOLF_PANTING`|`mob.wolf.panting`| Tamed wolf panting |
208
207
|`eSoundType_MOB_WOLF_WHINE`|`mob.wolf.whine`| Wolf whine |
209
208
|`eSoundType_MOB_WOLF_SHAKE`|`mob.wolf.shake`| Wolf shaking off water |
|`minecart.*`|`minecart.base`, `minecart.inside`| Minecart movement |
@@ -450,10 +474,9 @@ The master volumes (`m_MasterMusicVolume`, `m_MasterEffectsVolume`) are set from
450
474
451
475
## Sound bank and driver
452
476
453
-
The Miles Sound System uses:
454
-
- **`HMSOUNDBANK m_hBank`** is the loaded sound bank containing all SFX (`Minecraft.msscmp`)
455
-
- **`HDIGDRIVER m_hDriver`** is the digital audio driver
456
-
- **`HSTREAM m_hStream`** is the current streaming music handle
477
+
In the original console builds, the Miles Sound System used a compiled sound bank (`Minecraft.msscmp`) containing all SFX, loaded into `HMSOUNDBANK m_hBank`. `HDIGDRIVER m_hDriver` was the audio driver handle, and `HSTREAM m_hStream` was the streaming music handle.
478
+
479
+
LCEMP replaces this with miniaudio. The `ma_engine` handles mixing and output, `ma_sound` instances manage individual sounds (up to 64 active in `m_activeSounds[]`), and `m_musicStream` handles the current streaming track.
457
480
458
481
Sound files and music files get registered through `add()`, `addMusic()`, and `addStreaming()` during initialization.
459
482
@@ -467,10 +490,14 @@ Audio resources are stored in:
467
490
468
491
## Platform-specific notes
469
492
470
-
- **PS3**: `initAudioHardware()` has a platform-specific implementation for Cell audio initialization
493
+
These notes apply to the original console builds, not LCEMP:
494
+
495
+
- **PS3**: `initAudioHardware()` has a platform-specific implementation for Cell audio initialization. There is also a `PS3_SoundEngine.cpp` with PS3-specific Miles integration.
471
496
- **PS4 (Orbis)**: Uses `int32_t m_hBGMAudio` for the background music audio handle
472
497
- **PS Vita**: Miles integration through a Vita-specific MSS build with `updateMiles()` called during the mixer callback
473
-
- **Xbox 360**: Uses native XAudio instead of Miles (no `mss.h` include)
498
+
- **Xbox 360**: Uses native XAudio instead of Miles (no `mss.h` include). Has its own `Xbox/Audio/SoundEngine.cpp` and `SoundEngine.h`
499
+
500
+
LCEMP uses miniaudio on all platforms. The `initAudioHardware()` method is a no-op stub that just returns its input parameter.
474
501
475
502
## MinecraftConsoles differences
476
503
@@ -518,4 +545,4 @@ A bunch of mob step sounds are added that LCEMP was missing:
518
545
519
546
### Bug fix
520
547
521
-
`eSoundType_MOB_CAT_HITT` (typo with double T) is fixed to `eSoundType_MOB_CAT_HIT`.
548
+
`eSoundType_MOB_CAT_HITT` (typo with double T in LCEMP) is renamed to `eSoundType_MOB_CAT_HIT` in MinecraftConsoles.
These are hardcoded `static const int` values on the class. They aren't remappable through the input system itself, but the `Options` class has a separate `KeyMapping` system for the Java-style key bindings (see below).
42
+
| Constant | Key | Value | Mutable? |
43
+
|---|---|---|---|
44
+
|`KEY_FORWARD`| W |`'W'`| Yes |
45
+
|`KEY_BACKWARD`| S |`'S'`| Yes |
46
+
|`KEY_LEFT`| A |`'A'`| Yes |
47
+
|`KEY_RIGHT`| D |`'D'`| Yes |
48
+
|`KEY_JUMP`| Space |`VK_SPACE`| Yes |
49
+
|`KEY_SNEAK`| Left Shift |`VK_LSHIFT`| Yes |
50
+
|`KEY_SPRINT`| Left Ctrl |`VK_LCONTROL`| Yes |
51
+
|`KEY_INVENTORY`| E |`'E'`| Yes |
52
+
|`KEY_DROP`| Q |`'Q'`| Yes |
53
+
|`KEY_CRAFTING`| Tab |`VK_TAB`| Yes |
54
+
|`KEY_CRAFTING_ALT`| R |`'R'`| No (const) |
55
+
|`KEY_CONFIRM`| Enter |`VK_RETURN`| Yes |
56
+
|`KEY_CANCEL`| Backspace |`VK_BACK`| No (const) |
57
+
|`KEY_PAUSE`| Escape |`VK_ESCAPE`| Yes |
58
+
|`KEY_THIRD_PERSON`| F5 |`VK_F5`| Yes |
59
+
|`KEY_DEBUG_INFO`| F3 |`VK_F3`| Yes |
60
+
|`KEY_VOICE`| (varies) | (varies) | Yes |
61
+
62
+
Most of these are `static int` (not const), so they can be remapped at runtime. Only `KEY_CRAFTING_ALT` and `KEY_CANCEL` are `static const int`. The `Options` class has a separate `KeyMapping` system for the Java-style key bindings (see below).
62
63
63
64
`MAX_KEYS` = 256 covers all Windows virtual key codes.
64
65
@@ -112,6 +113,7 @@ Mouse position is tracked separately:
|`HadRawMouseInput()`| Returns `m_hadRawMouseInput`, true when raw mouse delta was received this tick. Useful for detecting mouse activity independently of keyboard. |
115
117
|`HasAnyInput()`| Returns `m_hasInput`, which is true when any key or mouse event has happened. Used for auto-detecting whether to switch between controller and keyboard/mouse input modes. |
Copy file name to clipboardExpand all lines: src/content/docs/client/particles.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ The first dimension (3) supports rendering across multiple dimensions at the sam
55
55
|`crack(int x, int y, int z, int face)`| Spawn block-cracking particles on a face |
56
56
|`countParticles()`| Returns a string with particle counts for debug |
57
57
58
-
`render()` and `renderLit()` are called at different points in the frame. `render()` handles standard particles with additive or alpha blending. `renderLit()`handles particles that need proper world lighting (block break debris, item break debris).
58
+
`render()` and `renderLit()` are called at different points in the frame. `render()` handles standard particles with additive or alpha blending, including block break debris (`TERRAIN_TEXTURE`, layer 1) and item break debris (`ITEM_TEXTURE`, layer 2). `renderLit()`renders the `ENTITY_PARTICLE_TEXTURE` layer (layer 3), which includes footstep particles and huge explosion particles. These are rendered individually instead of batched, so they can set up their own GL state.
0 commit comments