IMA ADPCM sounds in mix files?

Bug #895891 reported by Chanterier
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ares
Fix Released
Medium
AlexB

Bug Description

I have recently found out that Ares makes it possible to read sound files from game, which is awesome especially for those who use current Launchbase or an installer, instead of XCC Mod Creator.

However, it seems that game will only accept files in PCM format correctly, while audio files in audio.bag are in IMA ADPCM (same goes for EVA audio files btw). IMA ADPCM files that are placed inside a mix file and used through soundmd.ini will result in noise ingame.

This is a particularlry bad thing as IMA ADPCM are much smaller in size (MO sounds are 60MB in PCM while 15MB in IMA. Same goes for original YR sounds when they are extracted through XCC Sound Editor - 120MB in PCM while in audio.bag, in IMA ADPCM format they take 30MB only).

Also, I don't really understand why it happens because EVA sounds are in IMA ADPCM as well and game reads them correctly.. It'd be great if someone checked if he has the same problem as well.

Revision history for this message
FS-21 (jagarni1983) wrote :

To test it (r823) I got some .wav sound files of a .mix file that I made time ago and I converted them into IMA ADPCM format as suggested (with XCC mixer) and dropped directly in the game folder (it should be the same as dropped in a mix file), now those sounds are only noise ingame but those converted sounds can be reproduced in any audio player.

Revision history for this message
Starkku (starkku) wrote :

I can further confirm from my own tests that this is a real issue. Any IMA ADPCM encoded wave files that are called from soundmd.ini that are not in audio.bag are played as static noise ingame.

Revision history for this message
Graion Dilach (graiondilach) wrote :

I did another way of test, by extracting a sound (iseaexb.wav) from audio.bag, converting it to IMA ADPCM 22 kHz mono and check their file sizes.

The result was that my isea was less with 1 kB. Is audio.bag contains more thing coded into their IMA ADPCM files then the standard version?

Revision history for this message
Graion Dilach (graiondilach) wrote :

OK, I did another test by extracting a file from audio.bag, then cutting it out to find out the differences. The test-file was ibruatta.wav.

The version in audio.bag doesn't have the general RIFF wave header, it starts with the first chunk directly. But in the end of the file, there is 457 bytes of additional data... and I don't know what it is.

Will do another test, if the game could play an IMA ADPCM wav without the header.

Revision history for this message
Graion Dilach (graiondilach) wrote :

Test finished. The game didn't played the headerless IMA ADPCM... it's silent instead.

Revision history for this message
DCoder DCoder (dcoder1337) wrote :

After looking at pd's code for this, all the flags of the audio sample are hardcoded to specific values, which I think is the source of the problem since you can manually change those values in the IDX but not in this case. I'd like someone with knowledge of the flag differences at byte level to state what is different in the IDX headers of PCM and IDA ADPCM sounds.

Revision history for this message
Graion Dilach (graiondilach) wrote :

IDX format:

Header 12 byte: 47H 41H 42H 41H 02H 00H 00H 00H and number of files (Little Endian form), 4 byte

Files 36 byte: filename 16 byte (extended with some additional data, exact circumstances unknown) offset 4 byte, size 4 byte, frequency 4 byte, flag 4 byte, chunk size 4 byte.

Except filename, all are little-endian.

Revision history for this message
Graion Dilach (graiondilach) wrote :

Because I missed out posting here, flag values - just for backup.

Flag 1 - channels
Flag 2 - PCM
Flag 4 - always on
Flag 8 - IMA ADPCM.

OK, feedback is provided. Although mostly on chat but is provided.

Revision history for this message
DCoder DCoder (dcoder1337) wrote :

Right, thanks, and this will be looked into after 0.2.

Revision history for this message
Apollo (apollo) wrote :

Flag values??? What you call flag is actually format type identifier entry after the frequency and no, there is no separate value to tell channels for example, it is all done in one and same.

list of proper format types within index is following

02 00 00 00 (PCM Mono 8-bit) ;Nobody likes
03 00 00 00 (PCM Stereo 8-bit) ;8 bit pcm quality anyway...
06 00 00 00 (PCM Mono 16-bit)
07 00 00 00 (PCM Stereo 16-bit)
0C 00 00 00 (IMA ADPCM Mono)
0D 00 00 00 (IMA ADPCM Stereo)

in case of IMA, afterwards follows the 4 byte value of adpcm block/chunk size used in encoding, this varies depending on encoder/khz.

Simplest would be to have a fetching routine get all the info from wav header and change to idx equivalents to pass on to the bag sound engine decoder.

Revision history for this message
Graion Dilach (graiondilach) wrote :

In assembly, bit values used for boolean checks are called flags.

Those are also bit flags. If you convert your sole value into binary, you'll realize what I mean. They are in the same byte, but that byte is used in bitlevel.

Revision history for this message
Graion Dilach (graiondilach) wrote :

On a more realted note... so Flag 4 is 8-bit 16-bit switch. I see, thanks.

AlexB (alexander-b)
Changed in ares:
assignee: nobody → AlexB (alexander-b)
milestone: none → 0.a
status: Confirmed → Fix Committed
AlexB (alexander-b)
Changed in ares:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.