Stage soundscape, 3-D sends and the listener
Our reading of the executable and of the st03
/ st02 layouts and banks
(stagesound.py, the bank reader of
pdsound.py). It answers the
playtest note “ambient sounds are missing from
the level”: yes, the rebuild plays none
of the stage bank, and it also has no
footsteps, no movement / landing sounds and no
3-D falloff of the game’s kind. Confidence
H (read in the code and checked
against the files) unless marked. Not confirmed
by ear: in the reference recordings the music
covers the ambience (see the end of the
section).
What a match plays with no skill use
The Palace (st03, stage bank
MapSEShoppingMall, parameter group
3). All from the stage-wide EF00 list
(17 sound entries), started when the stage
starts:
| Stage cue | Entries | How | Sound parameters (group 3) | Bank cue |
|---|---|---|---|---|
| 0 | 1 | held bed, no position | class 2, held | volume 80; two tracks of one stereo loop (3.3 s, 16 kHz), fine tune +60 / −30 cents; sends front 125 + rear 60 and front 60 + rear 125 |
| 1 | 10 | held, positional: five points at height 50.8 and the same five at 110.3 (the two floor levels) | class 2, held, positional; near 50, far 200, linear, spread 34 % | volume 30; four tracks of one mono loop (12 s, 22 kHz) at −1, +1, −5, −6 semitones, started 0 / 3.5 / 3.5 / 2 s in; each track sent to one side or both |
| 4 | 6 (two share a point) | positional one-shot, interval 90: one play every 91 ticks, forever | class 2, positional; near 0, far 140, linear, spread 20 % | volume 50; a ~9 s phrase: track 1 = five short one-shot clips (0.14–0.78 s) at 0.03 / 1.03 / 1.7 / 5.3 / 8 s, track 2 = a quiet looping clip gated by the event length at the same times |
| 3 | none | not placed in st03 / st13 / st23 and no code site plays it (M) | as cue 4 | the same clips in another order (a second drip phrase) |
Cue 2 is an empty slot. The entries of cue 4 play 3.03 s apart while the phrase is ~9 s long, so about three phrases of each emitter overlap.
st02 (stage bank
MapSEHighway, group
2).
| Stage cue | Who | How | Sound parameters | Bank cue |
|---|---|---|---|---|
| 2 | the one EF00 sound entry | held bed, no position | class 2, held | volume 30; two tracks of a 2.3 s loop, left only / right only, 0 and −2 semitones |
| 0 | the sand storm object | started once, no position; volume each tick = clamp(storm intensity, 0, 1) (“Stage sounds”) | class 2, held | volume 110; four tracks of a 6.8 s loop at 0 / −2 / +1 / +6 semitones spread over the four corners |
| 1 | near papers | held, no position (M) | class 2, held | volume 55; three tracks of a 6.5 s loop, effect send 60 |
| 3–5 | thunder: st12 only | — | class 2 | stereo one-shots, 3.6 s |
| 6 | st12’s second entry | — | class 2, held | — |
Every stage also has, from the common bank (earlier sections): footsteps (surface table, “Match, menu and footstep sounds”), the movement and landing cues of the character code, the surface sound by ground attribute, the lock-on and refused cues, the aura point cue, the countdown, and the battle music at the music option’s level.
Ours (main, 11-14): the
music, the countdown, lock-on, refused and aura
point cues, skill / hit / voice / stage-object
cues. pdsound.py converts
common and the voice banks only; no
MapSE bank is converted and nothing
reads the EF00 sound entries. So on the Palace
the room bed, ten water points and six drip
emitters are silent, and on st02 the bed, the
storm bed and the paper loop.
Play volume: option and volume class
Both play requests (plain 0x140240870, 3-D 0x140240a00) compute v = volume argument × sound option × class volume, truncated to an integer (0x1000 = 1.0):
- sound option = the float at 0x1405336b8 (option / 100, “Music volume, the sound volume option”; the init value before the options load is 0.8);
- class = soundparam flags bits 0–1 of the cue’s record; class volume = the float table 0x1405336c0 at index 1 << class (indices 1, 2, 4, 8). The sound system init 0x14023fd40 sets all four to 1.0. 0x140240810(mask << 3, value) sets the classes of a mask; its one user is a fader object (0x1401baa40) that ramps a class mask down and up over a tick count (which scripts or events drive it: not followed, M). So in a match every class is at 1.0.
- Classes of the two stage groups: every filled record is class 2. The request keeps (8 << class) | 1 as its flag word.
The listener
One routine sets it, 0x1402403a0(matrix, position, listener index), called once per frame from the camera commit 0x14012bfc0:
In a battle the listener is the player’s character, not the camera: the position is the character position (C + 0x12e40) and the matrix is the character’s body matrix (C + 0x12d80: identity turned by the facing word C + 0x12e5c, then by C + 0x12e60) with its translation replaced by the point at C + 0x13f2c. The player is the local one; in split-screen (battle mode 6) the one whose view is being set up, with the view’s index as the listener index. (M: read in the code only; which point C + 0x13f2c is was not followed, it is only used as the second listener point of the Doppler step.)
Outside a battle: the camera point 0x14059e150 with an identity matrix turned by the yaw word 0x140534730.
The routine keeps, per listener index (two of them, 0x18 bytes each from 0x14059e020), the position and the second point with their previous values, and turns five speaker directions by the matrix into 0x14059e0a0.. (one shared set). The directions are set at init, with s = 1 / √2, x to the right and z forward:
Speaker Send id Direction front left 0 (−s, 0, s) front right 1 (s, 0, s) centre 2 (0, 0, s) rear left 4 (−s, 0, −s) rear right 5 (s, 0, −s)
3-D sends (0x140241440)
For a positional request the routine fills the request’s eight send scales (the per-send scale of “Speaker sends”, 0x1000 = 1.0) from the emitter position E, the listener position L and the cue’s soundparam record (near and far in tens of units, spread in percent):
- d = |L − E|. If d ≥ far: all eight scales are 0 (the request stays alive, silent).
- a = 1 when d ≤ near, else 1 − (d − near) / (far − near).
- Distance volume by the curve byte:
- 0 (linear): V = v × a;
- 1: V = v when a ≥ 0.9, else v × (−log10(1 − a));
- 2 and up: V = 0 when a ≤ 0.1, else v × (1 + log10(a)).
- In split-screen (battle mode 6) V is halved.
- For each of the five speakers: P = L + direction × d (the speaker sits at the emitter’s distance), g = 1 − |P − E| / (spread / 100 × 2 × far). The scale is 0 when g < 0, else V × min(g, 1), capped at 0x1000.
- The three sends without a direction (LFE id 3, effect sends ids 11 and 12) get v × a (the linear factor whatever the curve, not halved).
The event’s own send levels (0..127) still multiply these per send (“Speaker sends”), so a cue’s left / right layering survives the panning. Consequences: a source at the listener (d = 0) is equal in all five speakers; the farther it is, the narrower it gets (at distance d a speaker at angle φ from the source is |P − E| = 2 d sin(φ / 2) away). Palace water points: silent from 200 units, full inside 50, spread length 136 units. Drips: silent from 140 units, spread length 56 units.
Per tick (0x1402400f0 → 0x140240210): each of the 84 request slots that is playing is updated: positional ones through 0x140240c10 (sends recomputed from the stored emitter position and the current listener, plus the Doppler pitch), the others through the plain volume update. In split-screen a positional start makes a second request in slot + 84 for listener 1. The slot steal policy was not followed (M for the pool size as the voice limit).
Not decoded: what the effect sends (ids 11, 12) feed on the PC port; the fader’s users; the Doppler step’s details; the meaning of the event word at 0x14.
Mix: the game against ours
| Game | Ours (main) | |
|---|---|---|
| Stage bank cues | played as above | not converted, not played |
| Positional falloff | per cue: near / far / curve from soundparam, linear for both stage groups; silent beyond far | Godot’s inverse-distance default with one unit size and max distance for every cue |
| Panning | five speakers around the character, width from the cue’s spread and the distance | Godot 3-D panning around the camera |
| Listener | the character (position and facing) | the camera |
| Level of a bed | Palace bed: volume 80 × track 100, send 125 → about −6.7 dB, × the sound option (60 → about −11 dB in all); music at the default option about −4.7 dB | — |
| Reverb | none on the PC port (DSP_*.bin
loaded and freed, “Sound banks”); the effect
send levels exist in the events (60–100 on the
highway cues, send 12 on the Palace cues) but
their bus is not decoded |
none |
| Event length (0x1C) | ends looping events | not applied: a looping event would never end |
Recordings. One private recording has the PC port idle on the Palace (0–206 s) and our build on the Palace (668–772 s), both with the music. Spectrograms of 30 s of each show the music in both and nothing that can be told apart as the bed or the drips, so the recordings neither confirm nor contradict the list above. A recording with the music option at 0 would.
Rebuild (ambient build, 11-14)
- Converter.
pdsound.py(struct reader for the STH2 chunks,soundparam.datandcharaset.dat) converts the nineMapSEbanks with the others, writesstage_banks(area → bank, the stage file table entries 70–78),param_groups, per tracklength_ms/end_mode, and per stage layoutstages.stNN = {area, emitters}fromstagesound.stage_emitters(): the stage-wide list at its positions, then the state-0 EF00 list of every placed object, each entry turned and moved by its placement (Rz·Ry·Rx, then the position; as the object placement in “Stage objects”). Per stage the result matches the table in “Stage sounds” (st03 17 entries, st08 29 object one-shots, st05 / st15 / st25 five common cue 79 points, st06 / st26 two common cue 17 once after 52 ticks). Which placements spawn their list in the exe was not traced (INFERRED: all of them). - Near papers’ cue (now H): the near-paper tick starts stage cue 1 once without a position and each tick sets its volume to the storm object’s value at +0xec (0x1402441b3), the same value the storm’s own cue 0 takes. So both follow clamp(intensity, 0, 1) × 0x1000.
- Godot.
PdSound.request()starts a request (all tracks of a cue; at most 84 live; a new one with all busy is dropped). A positional request (soundparam flag 0x10 and a position) gets its eight send scales fromsends_3d()(the routine above, with the decoded constants: near / far × 10, spread × 10 × 0.001 × 2 far, curve thresholds 0.9 / 0.1, split-screen × 0.5), recomputed every frame byPdSoundMixerfromlistener_frame(): the local Player’s position and facing (main.gd setsPdSound.listener), the camera only without one. A plain request’s scales are all v = volume × option × class volume. Per track the six speaker gains fold to left / right (stereo_gains()); a track whose sides differ plays as a left player on busPdSendLand a right one onPdSendR(each bus pans hard to its side at −6.02 dB, so a mono clip keeps its level), equal sides play one stereo player.PdStageSoundruns the emitters on the 30 Hz tick as described in “Stage sounds” and the storm’s two cues. - Check numbers (tests/test_ambient_scene.gd on the real Palace scene, sound option 60, v = 2457; a water point straight ahead of the Player; sends front L / R, centre, LFE, rear L / R, effect 11 / 12): d = 30 → 2042 2042 2298 2457 1455 1455 2457 2457; d = 125 → 364 364 897 1228 0 0 1228 1228; d = 199 → 0 0 9 16 0 0 16 16; d = 200 → all 0.
- Footsteps: not built. The per-foot routine 0x140231010 works on the character’s display object: the current foot’s index at +0x128, foot records of 0x58 bytes; a step fires when the record’s word +0xb0 is set while +0xb4 is clear and the record’s cooldown (+0xbc) is ≤ 0 (then 10); it plays table[attribute][column] + foot at the translation of the joint matrix the record points to (+0x80). The column is 0 for character state 7..11 and 1 otherwise (in a network match it comes from the remote player object’s +0x6d0: 1 → 0, 2 → 1). The writer of +0xb0 / +0xb4 (the contact signal) and the caller that passes the ground attribute were not found in this run.
Implementation notes for the rebuild
pdsound.py: convert the stage’sMapSEbank (by stage ones digit) into the index next tocommon; export each event’s length (0x1C) and stop the event’s player at start + length; export the soundparam record per cue (class, held, positional, near, far, curve, spread; group = bank’s group).Spawn the EF00 sound entries (“Stage sounds” notes): the Palace needs 1 bed, 10 held points and 6 one-shot emitters with a 91-tick period; st02 needs its bed, the storm bed (volume = storm intensity each tick) and the paper loop.
A cue with several tracks plays them all, each with its start delay, transpose and sends; the drip phrase’s track 2 needs the event length.
Positional cues: replace Godot’s attenuation with the routine above (per-speaker scales from L, E, the record; fold the five speakers to stereo as the existing down-mix does), recomputed each tick; listener = the local character’s position and facing.
Play volume = argument × sound option × class volume (1.0 in a match).
Record a Palace idle of the PC port with the music option at 0 to check the levels by ear.
(ambient r2, 11-15) Update rate. The mixer starts and stops tracks every frame (delays, event lengths) but recomputes the sends once per game tick (30 Hz), as the game’s tick pass. A positional request made without
followkeeps the position it was made at (as the game’s request stores the emitter position once).Mix levels at the default options (both 60), checked on the real scene: per speaker the Palace bed’s first track (cue 80, track 100, front send 125) plays −11.20 dB and music track 1 (volume and sends 127) −4.67 dB, the decoded levels; our stereo fold divides both by 1.7071 (−4.65 dB), so they play −13.35 / −9.32 dB and keep the decoded 6.53 dB between them.