Sound banks (Assets/Data/Sound/*.bin, ‘STH2’)

Read by pdsound.py → sound/index.json + one WAV per clip. The container layout (STH2 header, REAL / REAT / TRAT / EVNT / WAVE chunks) is from Esper-RE (sth2.h, esper_sth2.hexpat, GPL-3.0); the field meanings below, the codec, the id → bank mapping and the voice selection are our own reading of the data and the executable (our reading of the machine code; addresses only in the branch report). All values little-endian.

Files. common.bin (skill and battle sounds), BattleVo_<x>_{en,ja}.bin (one voice bank per character; setup/charaset/charaset.dat entry +0x3C names it, the game appends _<lang>), BossSE_*.bin, MapSE<area>.bin, Title_Logo.bin are STH2 banks. DSP_<area>.bin are not: they are effect images for the Xbox’s audio DSP (reverb and effect chains, one per area), and the PC port never applies them. Its loader (0x14021a6a0) still picks the file by area number mod 10 (name table 0x1402dc970) and reads it into a 0x8000-byte buffer next to the area’s sound bank, but the load callback (0x14021a5a0) only registers the bank; for the other buffer it calls the free routine and clears the pointer. So there is nothing to convert, and the port has no stage reverb from these files. (What they are: shared notes; the PC loader and callback: read here.)

Header (0x40). 0x00 STH2, 0x04 0xF8, 0x24 offset of REAL, 0x28 offset of WAVE, 0x2C.. 0xFF padding. 0x44 a bank level 0..127 (not applied).

REAL (cue table): 0x08 count n, 0x10 n × s32 offsets from the REAL start; ≤ 0 = no cue. The cue number is the index in this table; it is what the game plays.

REAT (cue, 0x30 + 4 × tracks): 0x08 track count, 0x10 volume 0..127, 0x14 pan (64 = center), 0x30 s32 offsets of the tracks from the REAT start (−1 = empty slot).

TRAT (track, 0x30 + events × 0x100): 0x08 event count, 0x0C 0x100, 0x10 volume 0..127, 0x14 pan. All tracks of a cue play together (layered).

EVNT (0x100):

off meaning
0x18 start time in ms (multiples of ~17 ms = 60 Hz frames; keyframe events step it by 100–150 ms)
0x1C length in ms (ambient run, 11-14): the event is stopped at start + length (0x1402802cd sets the end time, the track update 0x14027f161 compares its clock with it). 0 with the word at 0x14 equal to 1 = no end. For a one-shot clip it is the clip’s length; for a looping clip it is how long the loop sounds (the Palace drip cues gate a looping clip for 33..1666 ms). (ambient build) Word 0x14 is 1 on every looping event and 0 on one-shots in all banks (2722 one-shots with a length, 136 loops with 0 = no end, 23 gated loops); pdsound.py writes length_ms / end_mode per track and PdSound stops the track at start + length
0x24 kind: 1 = 16-bit PCM clip; 0 and 105 have no clip (clip index −1): keyframes, not decoded
0x28 sample rate (Hz), per event: 20000 for most, 14000..44100
0x2C channels (1 or 2)
0x30 bits: 16 for PCM
0x34 / 0x38 loop start / end in sample frames, −1 = no loop (pdsound.py clamps the end to the clip)
0x3C clip byte size (equals the WAVE entry, or 8 more: the entry wins)
0x40 an offset (0 for every PCM event)
0x58 s32 fine tune in cents (−90..90; 0 for most)
0x5C s32 transpose in semitones (−24..23 in common.bin; 0 for about half the PCM events)
0x60 12 in every event (not applied)
0x64 s32 attenuation of the voice in mB (hundredths of a dB) below full: 200 for most, 0 for some HUD cues
0x68..0xA7 eight (send id, level 0..127) pairs, ids 0, 1, 2, 3, 4, 5, 11, 12 in that order: the speaker sends (below)

Speaker sends (the exe’s mixer, 0x14027edf0 copies the pairs, 0x14027f36f..0x14027f3de turns them into levels, 0x14027e5de.. hands them to XAudio2). Ids 0..5 are the six outputs of a 5.1 matrix (front left, front right, centre, LFE, rear left, rear right), id 11 the level of the send to a second (effect) output, id 12 is not read there. Per send the level is x = level × send scale × s >> 16, with s = (play volume × cue volume × track volume) >> 9 (times a master scale 0x1000 >> 12, i.e. 1), and the matrix entry is 2048 · log10(x / 32768) mB (x = 0 counts as 1), as gain 10^(mB / 2000); a send at 127 with all volumes at 127 and a send scale of 0x1000 is about full. The voice’s own volume is 10^(−attenuation / 2000). Most events send 125 to the four front/rear outputs; the HUD aura point cue sends 60 front and 30 rear with no attenuation (≈ 9 dB below what a plain cue × track gain gives). pd_sound.gd track_gain() folds the six sends to its one player. | 0xF0 | clip index in WAVE |

WAVE: 0x04 chunk size, 0x08 count, 0x10 count × u32 offsets from the WAVE start; a clip runs to the next offset (the last to the chunk size). Raw PCM, no header; the rate and channels come from the events that play it (no bank has two events disagreeing).

Codec. Every audible event in this build is 16-bit PCM (no ADPCM/XMA): 2085 PCM events in common.bin, all clips non-silent.

Which sound plays (executable). The game loads common.bin into bank slot 0, the boss bank into slot 4 and player p’s voice bank into slot 3 + p.

Pitch (executable). Starting an event (0x140280143..0x1402801bf) copies its rate (0x28), fine (0x58), transpose (0x5C) and the first pair’s key (0x60, 12 in every event seen) into the voice; the play call’s pitch (0x1000 = 1.0; every call site we follow passes 0x1000, the Doppler path caps it at 0x2000) goes beside them. Each update (0x14027f42d..0x14027f51f) sets the voice’s output rate to rate × 2^((100 × transpose + fine) / 1200) × (1 + (2^(range/12) − 1) × (pitch / 0x1000 − 1)), range being the 0x60 value, at least 188 Hz (0xbc), and the source voice’s frequency ratio to that over the clip’s own rate. So a clip shared by several cues plays at a different pitch in each (clip 189 of common.bin at transposes 0, −1, −3, −4, −12). pdsound.py writes key, fine and rate per track; PdSound.track_pitch applies them.

Not applied in the rebuild: the cue / track pan bytes (0x14), the keyframe events and the bank level. (ambient build 11-14) The 3-D sends, the event length and the left / right sides of the speaker sends are applied (“Stage soundscape, 3-D sends and the listener”, Rebuild).