OBD:SNDD/aif: Difference between revisions

m
link fix and section name tweak
m (replaced formula GIFs with Math markup; replaced nowiki tags around equals signs with new {{=}} magic word)
m (link fix and section name tweak)
 
Line 7: Line 7:
No AIFC format other than "ima4" seems to be supported by Oni, therefore we are only documenting "ima4".
No AIFC format other than "ima4" seems to be supported by Oni, therefore we are only documenting "ima4".


==ima4 as stored in AIFC==
==IMA4 as stored in AIFC==
Below is the header of one of Oni's sounds (mono) stored as an .aif file. Note the [[wp:Endianness|Big Endian]] order.
Below is the header of one of Oni's sounds (mono) stored as an .aif file. Note the [[wp:Endianness|Big Endian]] order.


Line 117: Line 117:
The channel count is either 2 or 1 depending on whether the "2" bit of the flags (at 0x08) is set: if the bitset's value is 0x00000001 then the sound is mono, if the bitset's value is 0x00000003 then the sound is stereo. Knowing the channel count, you deduce the frame count (number of 34- or 68- byte frames) by dividing the .raw size by either 34 (mono) or 68 (stereo); it should divide evenly.
The channel count is either 2 or 1 depending on whether the "2" bit of the flags (at 0x08) is set: if the bitset's value is 0x00000001 then the sound is mono, if the bitset's value is 0x00000003 then the sound is stereo. Knowing the channel count, you deduce the frame count (number of 34- or 68- byte frames) by dividing the .raw size by either 34 (mono) or 68 (stereo); it should divide evenly.


Next you create an AIFC file based of the template described [[#ima4_as_stored_in_AIFC|ABOVE]] and adjust it as follows (don't forget about Big Endian!).
Next you create an AIFC file based of the template described [[#IMA4 as stored in AIFC|ABOVE]] and adjust it as follows (don't forget about Big Endian!).
*The SNDD's .raw data must be copied into the SSND section of the AIFC file, starting at 0x3A. Copy as-is, no byte swapping required.
*The SNDD's .raw data must be copied into the SSND section of the AIFC file, starting at 0x3A. Copy as-is, no byte swapping required.
*At 0x04, set the remaining file size to the size of the copied .raw data + 50 (Big Endian order!).
*At 0x04, set the remaining file size to the size of the copied .raw data + 50 (Big Endian order!).
Line 128: Line 128:
In Vanilla Oni (PC retail) there are no SNDDs that use IMA4 compression, so the situation described here is not very likely. If you need to do it anyway, then you essentially need to look up two things in the .dat part of the SNDD: the channel count at 0x0E and the frame count at 0x18. The frame count multiplied by 34 and by the channel count gives you the size of the .raw part (unlike in all the other situations, the size will not necessarily be stored explicitly in the SNDD, because the engine uses the frame count instead), which allows you to retrieve the IMA4 stream from the .raw file.
In Vanilla Oni (PC retail) there are no SNDDs that use IMA4 compression, so the situation described here is not very likely. If you need to do it anyway, then you essentially need to look up two things in the .dat part of the SNDD: the channel count at 0x0E and the frame count at 0x18. The frame count multiplied by 34 and by the channel count gives you the size of the .raw part (unlike in all the other situations, the size will not necessarily be stored explicitly in the SNDD, because the engine uses the frame count instead), which allows you to retrieve the IMA4 stream from the .raw file.


Next you create an AIFC file based of the template described [[#ima4_as_stored_in_AIFC|ABOVE]] and adjust it as follows (don't forget about Big Endian!).
Next you create an AIFC file based of the template described [[#IMA4 as stored in AIFC|ABOVE]] and adjust it as follows (don't forget about Big Endian!).
*The SNDD's .raw data must be copied into the SSND section of the AIFC file, starting at 0x3A. Copy as-is, no byte swapping required.
*The SNDD's .raw data must be copied into the SSND section of the AIFC file, starting at 0x3A. Copy as-is, no byte swapping required.
*At 0x04, set the remaining file size to the size of the copied .raw data + 50 (Big Endian order!).
*At 0x04, set the remaining file size to the size of the copied .raw data + 50 (Big Endian order!).
Line 136: Line 136:
That is all. Save the file and it should work.
That is all. Save the file and it should work.


<center>[[OBD:SNDD#Mac_and_PC_demo|Back to Mac SNDD (.dat part)]]</center>
<center>[[OBD:SNDD#Mac and Windows demo|Back to Mac SNDD (.dat part)]]</center>


{{OBD}}
{{OBD}}