Prototype icon indicating copy to clipboard operation
Prototype copied to clipboard

Play sounds from AMB files

Open maxpetul opened this issue 3 years ago • 5 comments

Right now we can play the sounds accompanying animations but only if they're stored as WAV files, and many are in AMB files. The first step is to decode these files. As of writing this, I have done most of the job but haven't finished and polished the results. If anyone is interested in working on this, contact me and I'll send you what I have. Otherwise I'll update this issue when I'm done with the decoding, whenever that will be.

maxpetul avatar Feb 02 '22 04:02 maxpetul

Hidden knowledge can more easily be lost, so please share what you have. Please toss what you have on the currently-empty repo wiki and/or send it to me.

You're clearly way ahead of me, but I'll just say for the record that as best as I can tell, there is no actual audio in the .amb files. Others say it's similar to a MIDI file in that it sequences and mixes sounds, in this case referencing external WAV or MP3 files.

JimOfLeisure avatar Feb 14 '22 22:02 JimOfLeisure

Okay, I'll post what I have once I get it into a presentable state, some time within a few days. Are you planning to implement support for AMB files, and soon?

You're right that the files have no actual audio data. They just combine other audio files with some time offsets and random effects. I believe AMBs were originally intended to do some complex things, but for what they're actually used for in Civ 3, they're massively overengineered. F.e., as far as I can tell the only point of the embedded MIDI file is to specify the times at which the component audio files are supposed to be played. So you have to go through all the trouble of parsing a MIDI file and at the end all it tells you is to play "this.wav" at 0.123 sec, "that.wav" at 0.456 sec, etc.

maxpetul avatar Feb 17 '22 01:02 maxpetul

Since AMB is over-engineered and opaque, can we just interpret it on load and not really deal with the file internally? AFAIK nobody has been able to make or modify a AMB so it would be preferred to orchestrate (pun intended) a series of audio files directly in our own format.

WildWeazel avatar Feb 17 '22 05:02 WildWeazel

Yeah I think that's the best approach. For all their complexity AMB files contain very little relevant information. They could be simplified down to a list of wave file names, each with a time delay, bounds for randomized pitch/tempo, and bounds for randomized something else (volume? I still haven't looked into that). Of course it's possible I missed something, I haven't inspected every single AMB file, but of the ones I've inspected, they could all be simplified like that.

maxpetul avatar Feb 18 '22 00:02 maxpetul

Here's my work so far on AMBs: https://github.com/maxpetul/Civ3AMBAnalysis Also I opened a discussion thread here: https://forums.civfanatics.com/threads/amb-format-analysis.675489/

maxpetul avatar Feb 20 '22 23:02 maxpetul