Skip to content

Play SOUND_TRIGGER tags in SuperView - #409

Closed
DerpyNewb wants to merge 1 commit into
donkeyProgramming:masterfrom
DerpyNewb:pr/superview-sound
Closed

DerpyNewb wants to merge 1 commit into
donkeyProgramming:masterfrom
DerpyNewb:pr/superview-sound

Conversation

@DerpyNewb

Copy link
Copy Markdown
Contributor

hey, this one is for #354 (Audio for SuperView), and most of #356. SuperView gets a Sound box: tick it and the SOUND_TRIGGER tags play their sounds as the playhead crosses them, so you can hear footsteps, swooshes and grunts land on the frames they're tagged on

what plays

  • the triggers in all four files a slot plays with: the clip meta, the persistent meta, the slot's .snd.meta and the persistent row's .snd.meta. the two .snd.meta files are read only, there's no tab for them
  • each tag is looked up the way the game does it: the audio_metadata_tags_tables row for the tag (exact spelling, the copy the game keeps wins), its battle event, the event's Play actions, then down through the containers to the WEMs. random and sequence containers follow their playlist rules (weights, avoid repeat, shuffle, playlist order), switch containers play the case you pick
  • every switch group the triggers reach (ground surface and so on) gets a combo box under the Sound box, defaulting to the case the container plays when nothing's set
  • loop and paused frame steps are handled: tags at either end of a looping clip fire once per pass, stepping frames fires nothing, an edit while playing doesn't refire what was just passed, and a new slot never fires the last clip's tags
  • sounds start 26 ms early to make up for output latency. that's measured through WASAPI loopback at the mixer's 30 ms latency (median 23 to 28 ms over six runs of 20 firings), not guessed

the status lines under the box say what the triggers resolve to: "N triggers: X play, Y silent in game, Z not supported", then one line per trigger that plays nothing, saying why. "silent in game" is a missing tags row, an event in no loaded bank, an event with no Play action and so on. "not supported" is a Wwise type this doesn't play (a dialogue event behind a 0x2303 action, which is what the melee hit sounds go through). it also lists a .snd.meta the slot names that no loaded pack has

it's off by default since turning it on loads the game's audio, and that's slow the first time after a game update (the audio cache gets built). the loading and decoding all happen off the UI thread, a vanilla attack's triggers can reach ~675 sources

why not SoundEngine

issue #356 says connect SuperView to SoundEngine, but triggers overlap all the time (a swoosh and a grunt at once, or the same footstep twice), and SoundEngine plays one stream. so this adds SoundTriggerMixer: it decodes each WEM once the same way SoundEngine does (WEM to Ogg to float), resamples to 48 kHz stereo and mixes as many voices as fire, on its own output (WASAPI, falling back to WaveOut). happy to fold it into SoundEngine instead if you'd rather have one playback path, Pear

things to look at

  • Shared.GameFormats: the agent rules say changes there need your OK, so flagging it. this adds three new files under Shared/GameFiles/DB (a small DB table reader: DbTableReader, DbSchema, DbTables) and changes nothing that's already there. the column layouts are an embedded extract of RPFM's schema_wh3.ron, only audio_metadata_tags_tables (versions 5 to 22). SchemaManager is commented out so there was nothing to hook into. if you'd rather keep GameFormats untouched I can move the three files into Editors.Audio, only the sound code uses them for now
  • AudioRepository gets two locks: one around the lazily filled lookup dictionaries and the swap a load ends with, one so loads run one at a time. SuperView looks up from the UI thread and a background thread at once, and the plain dictionaries weren't safe for that. a lookup waits for another lookup or the swap, never for a whole load. Dispose doesn't wait for a load in progress, and a load that ends after it lets go of what it opened
  • Editors.AnimationMeta now references Editors.Audio, and SuperView takes an IAudioRepository (it's scoped, so each SuperView has its own)
  • small additions outside SuperView: AnimationPlayerViewModel.Looping (raised before Loop jumps back to frame 0, since that jump is a paused frame set and can't be told apart otherwise), SoundMetaData / PersistSoundMetaData on SceneObject, and SoundMetaName / SoundMetaPersistName on BinAnimationViewModel, set when a slot is picked
  • the status lines are English only, like the other runtime messages in SuperView. the Sound box label is in En/Fr/Cn
  • campaign: the resolver handles the campaign event column too, but SuperView only lists battle animation sets, so it always plays the battle event

files

  • Editors/Audio/SoundTriggers/: new, AudioMetadataTags, SoundTriggerResolver, SoundTriggerSession, SoundTriggerCrossing, SoundTriggerMixer
  • Editors/Audio/Shared/Storage/AudioRepository.cs: the locks
  • Editors/MetaDataEditor/AnimationMeta/SuperView/SuperViewViewModel.Sound.cs: new, the SuperView side
  • SuperViewViewModel.cs, EditorView.xaml: the hooks and the Sound box
  • BinAnimationViewModel.cs, SceneObject.cs, SceneObjectEditor.cs, AnimationPlayerViewModel.cs: as above
  • Shared/GameFiles/DB/: new, the three reader files
  • Shared/EmbeddedResources/Resources/Db/schema_wh3_extract.txt: new
  • tests: Editors/Audio/SoundTriggerTests.cs (new), AudioCacheTests.cs (the lock tests), Test.AnimationMeta/SuperViewSoundTests.cs, SoundTriggerGameTests.cs, AudioMetadataTagsTableTests.cs (new)

testing

  • SoundTriggerTests (Test.Audio): the resolver on an in-memory bank, one case per Wwise action type, the playlist rules, the crossing rule (loop, paused steps, speed, the lead wrapping at the clip edge) and the mixer with a mocked device. AudioCacheTests gets the repository lock tests. 137 passed, 0 failed
  • SuperViewSoundTests (Test.AnimationMeta): SuperView on Throt's ATTACK_5 from Data/Throt.pack with the audio swapped for a small in-memory bank and the playback for recorders, so no device opens. covers all four files firing, the lead, looping, a slot change, edits while on, the switch pickers, a device that won't open or stops, and the Sound box bound in the view. 30 passed
  • AudioMetadataTagsTableTests: the DB reader on made-up files (F64 column, truncated, trailing bytes, unknown version) and which copy of a row wins across packs
  • SoundTriggerGameTests: the real game files, skipped without WH3_DATA. vanilla tags resolve to real WEMs, a made-up tag is silent, the melee hit sounds say not supported, and a real sword-and-shield attack's .snd.meta (16 triggers, 236 sources) resolves and decodes off the UI thread: about 3.5 s of first resolves and 12 s of decoding off it, 140 to 300 ms on it depending on load, most of which is SuperView's own scene update (~130 ms). the bar is 1 s, and running the jobs inline puts 16 s on it. all pass
  • I also broke each new hook on purpose (slot pick, persistent row, a picked animation, a new mesh, the Looping event, the scene update, field edits, deleting the only tag, the two .snd.meta files) and the tests caught every one
  • whole solution with WH3_DATA set: 2,738 results, 1 failed, 81 skipped (existing ignores, none from this PR). the failure was the game test asking the runner for the first editor's services instead of its own SuperView's; fixed, and Test.Audio (232 passed) and Test.AnimationMeta (230 passed) rerun clean
  • built AssetEditor.csproj the way pr-test.yml does, 0 errors

not tried by hand in this build yet. the same feature shipped in my fork's v2.2 release on 11-21, with a Sound tab for editing the .snd.meta on top, which I left out here

A Sound box in SuperView plays the SOUND_TRIGGER tags of the clip meta, the persistent meta, the slot's .snd.meta and the persistent row's .snd.meta as the playhead crosses them. Each tag goes through audio_metadata_tags_tables to its battle event, then through the event's Play actions and containers to the WEMs, as the game resolves it: random and sequence containers follow their playlist rules, and each switch group the triggers reach gets a picker. Status lines say what the triggers resolve to and why one plays nothing. The sounds play through a small mixer of their own, as triggers overlap and SoundEngine plays one stream.

Adds a DB table reader (Shared/GameFiles/DB) with the tags table's layouts from RPFM's schema, and makes AudioRepository's lookups and loads safe from two threads, as SuperView resolves off the UI thread.
@Pear-231

Pear-231 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Hello, this looks great but it might be worth holding on for now as I've got a separate implementation which handles the sound engine redesign to allow sounds to play concurrently and not lag behind animations.

@DerpyNewb

Copy link
Copy Markdown
Contributor Author

Hello, this looks great but it might be worth holding on for now as I've got a separate implementation which handles the sound engine redesign to allow sounds to play concurrently and not lag behind animations.

Copy that! 🫡

@DerpyNewb DerpyNewb closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants