Skip to content

Play the published sound in place of the disc's packs - #252

Open
SirFancyBacon wants to merge 1 commit into
TheMoonPeople:masterfrom
SirFancyBacon:sound-from-published
Open

SirFancyBacon wants to merge 1 commit into
TheMoonPeople:masterfrom
SirFancyBacon:sound-from-published

Conversation

@SirFancyBacon

Copy link
Copy Markdown
Contributor

Follows up the sound publishing (dcdata publish-sound, docs/AUDIO_FRAMEWORK.md): the published files were written but the game never played them. Now extraction publishes the sound and the game plays it.

What changes

Extraction publishes the sound. dcdata extract publishes it after baking textures and models. dcdata publish-sound still does it alone. Data from the first-run window has no published sound, as it has no baked textures or models, and plays the packs as before.

The game plays the published files. When the game loads a pack's load list, it finds the pack's .sound.json from the loaded bytes (DataReadSourceRange), so none of the 12 call sites change. Then it:

  • builds each bank from its bank.json and WAV samples with Kazarov's Bank::CreateFromJsonCandidates;
  • builds each sequence from its JSON with SqFile::CreateFromJson;
  • takes the list's .cfg settings (reverb, effect table) from the document;
  • reads the two volume tables (sqtbl, setbl) from their JSON.

A pack without a document, or a list, member or file that can't be read, plays the pack's own as before. The new code is port/src/sound/published.cpp. sound.cpp and snd.cpp change only where they use it; retail's walk of each load list stays as it is.

Title and opening sound is published too. The title (in every language) and the opening keep their sound in .pak packs along with their pictures and models. A .pak is now published when it holds a load list naming its own banks or sequences; on the retail data that's 12 of them, in titledat/ and opdat/. Kazarov names a pack's published sequences from a .snd path, so a .pak's are keyed as if it were one (titledat/title.sound/sequences/…, beside titledat/title.sound.json).

Datapacks can replace sound. Every published file is looked up in the active datapacks first, then in the game's data. The data side goes through data::DataMount(), a small read-only vfs mount over the game's data reader (folder or data.zip). A pack can therefore replace a pack's document, a bank, a sequence or a single sample by its path. The custom soundtrack (docs/SOUNDTRACK.md) still replaces a sequence by its name, whichever source the sequence comes from.

Not yet: removing the originals. The original packs are still extracted, and the game still reads each into memory before walking its lists. A follow-up removes them once the game no longer reads them.

Testing

  • New tests:
    • DataRead.APacksPublishedSoundPlaysInPlaceOfItsOwn: a synthetic pack with a published document plays the published sequence and volume.
    • DataRead.APackWithoutPublishedSoundPlaysItsOwn.
    • DataRead.TheDataMountFindsAndReadsTheGamesFiles.
  • SoundPublishRealData passes on the retail data with the .pak documents included: 230 packs sharing 230 banks, published in about 10 s.
  • I recorded the game's audio output (DC_AUDIO_WAV) from the retail data with and without the published files: the title, the opening, Norune and a dungeon floor with music and effects. All four pairs are identical sample for sample.
  • Full ctest -j4 passes on Linux, apart from the five Kazarov GPU tests that fail on lavapipe.

dcdata extract now publishes the sound in ChronicleTwo's formats as
part of the bake, and the game plays it: as it loads a pack's load
list it finds the pack's .sound.json, builds each bank from its
bank.json and WAV samples and each sequence from its JSON through
Kazarov's loaders, and takes the list's .cfg settings and the two
volume tables from their documents. A pack without a document, or a
file that cannot be read, plays the pack's own, as data the first-run
window extracts does.

The title's and the opening's packs hold their sound among their
pictures and models, so a .pak that holds a load list naming its own
banks or sequences is published too, its sequences named as a .snd's
would be.

Every published file is looked for in the active datapacks first, then
in the data, through a vfs mount over the game's data reader, so a
pack can replace a document, a bank, a sequence or one sample. The
custom soundtrack still replaces a sequence by its name.

The original packs are still extracted and read into memory before
their lists are walked; a follow-up removes them.

Recordings of the title, the opening, Norune and a dungeon floor are
identical sample for sample from the published data and from the
disc's packs.

This branch has not been deployed

No deployments
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.

1 participant