Jump to content

OBD:SNDD: Difference between revisions

47 bytes removed ,  Yesterday at 21:25
m
wording
m (the wiki has standardized around using "Windows" instead of "PC" which is ambiguous)
m (wording)
 
(One intermediate revision by the same user not shown)
Line 25: Line 25:
{{OBDtr| 0x04 | lev_id  |FFFF00| 01 00 00 06 | 3        | level 3 }}
{{OBDtr| 0x04 | lev_id  |FFFF00| 01 00 00 06 | 3        | level 3 }}
{{OBDtr| 0x08 | uint32  |FFC8C8| 01 00 00 00 | 1        | flags
{{OBDtr| 0x08 | uint32  |FFC8C8| 01 00 00 00 | 1        | flags
:1 - (compressed; always the same in Vanilla Oni)
:1 - (compressed; always the same in vanilla Oni)
:2 - stereo (mono if disabled) }}
:2 - stereo (mono if disabled) }}
{{OBDtr| 0x0C | uint16  |FFFFC8| 37 00      | 55        | duration in 1/60 seconds (game ticks) }}
{{OBDtr| 0x0C | uint16  |FFFFC8| 37 00      | 55        | duration in 1/60 seconds (game ticks) }}
{{OBDtr| 0x0E | uint16  |FFFFC8| 00 00      | 0x0000    | padding (unused in Vanilla Oni) }}
{{OBDtr| 0x0E | uint16  |FFFFC8| 00 00      | 0x0000    | padding (unused in vanilla Oni) }}
{{OBDtr| 0x10 | uint32  |C8FFC8| 5E 2A 00 00 | 10846    | size of the part in the raw file, in bytes }}
{{OBDtr| 0x10 | uint32  |C8FFC8| 5E 2A 00 00 | 10846    | size of the data in the raw file }}
{{OBDtr| 0x14 | offset  |C8FFFF| 00 B1 01 00 | 0x1B100  | at this position starts the part in the raw file }}
{{OBDtr| 0x14 | offset  |C8FFFF| 00 B1 01 00 | 0x1B100  | offset of the data in the raw file }}
{{OBDtr| 0x18 | char[8]  |FFC8FF| AD DE      | dead      | 8 unused bytes (padding; not part of the SNDD file) }}
{{OBDtr| 0x18 | char[8]  |FFC8FF| AD DE      | dead      | 8 unused bytes (padding; not part of the SNDD file) }}
|}
|}
Line 37: Line 37:
:The uint16 at 0x0E ''is'' loaded by the engine, and thus constitutes a potentially useful 16-bit field.
:The uint16 at 0x0E ''is'' loaded by the engine, and thus constitutes a potentially useful 16-bit field.
;Duration
;Duration
:The duration (number of game ticks) is rounded to the ''lower'' value (a.k.a. "floor") in Vanilla Oni data.<ref name="ticks">As an example, on Windows (both demo and retail), '''SNDDmus_ot7.aif''' consists of 152360 samples, which at 22.05 kHz corresponds to 6.90975 seconds, or 414.585 ticks; the duration, however, is indicated as 414 ticks and not 415. In other words, "duration" corresponds to the number of ''whole'' game ticks spanned by the sound's playback.</ref> In other words, it indicates the number of ''complete'' game ticks spanned by the sound's playback.
:The duration (number of game ticks) is rounded to the ''lower'' value (a.k.a. "floor") in vanilla Oni data.<ref name="ticks">As an example, on Windows (both demo and retail), '''SNDDmus_ot7.aif''' consists of 152360 samples, which at 22.05 kHz corresponds to 6.90975 seconds, or 414.585 ticks; the duration, however, is indicated as 414 ticks and not 415. In other words, "duration" corresponds to the number of ''whole'' game ticks spanned by the sound's playback.</ref> In other words, it indicates the number of ''complete'' game ticks spanned by the sound's playback.
;Compression
;Compression
:The effect of the "1" flag (or rather of its absence) is different in the Windows demo and Mac engines.
:The effect of the "1" flag (or rather of its absence) is different in the Windows demo and Mac engines.
Line 116: Line 116:
{{OBDtr| 0x04 | lev_id  |FFFF00| 01 00 00 06 | 3        | level 3 }}
{{OBDtr| 0x04 | lev_id  |FFFF00| 01 00 00 06 | 3        | level 3 }}
{{OBDtr| 0x08 | uint32  |FFC8C8| 08 00 00 00 | 8        | flags
{{OBDtr| 0x08 | uint32  |FFC8C8| 08 00 00 00 | 8        | flags
:1 - never used in Vanilla Oni; unknown (no effect?)
:1 - never used in vanilla Oni; unknown (no effect?)
:2 - never used in Vanilla Oni; unknown (no effect?)
:2 - never used in vanilla Oni; unknown (no effect?)
:4 - never used in Vanilla Oni; enables rudimentary format header and IMA4 decoding (overrules "8")
:4 - never used in vanilla Oni; enables rudimentary format header and IMA4 decoding (overrules "8")
:8 - always used in Vanilla Oni; enables fully-featured format header and PCM / MS ADPCM decoding }}
:8 - always used in vanilla Oni; enables fully-featured format header and PCM / MS ADPCM decoding }}
{{OBDtr| 0x0C | block[50]|FFC8C8| &nbsp;      | &nbsp;    | format header (MS ADPCM variant here; can also be IMA4, see below)}}
{{OBDtr| 0x0C | block[50]|FFC8C8| &nbsp;      | &nbsp;    | format header (MS ADPCM variant here; can also be IMA4, see below)}}
{{OBDtr| 0x3E | uint16  |FFFFC8| 37 00      | 55        | duration in 1/60 seconds (game ticks), rounded to the lower value }}
{{OBDtr| 0x3E | uint16  |FFFFC8| 37 00      | 55        | duration in 1/60 seconds (game ticks), rounded to the lower value }}
{{OBDtr| 0x40 | uint32  |C8FFC8| 56 28 00 00 | 10326    | size of the part in the raw file in bytes }}
{{OBDtr| 0x40 | uint32  |C8FFC8| 56 28 00 00 | 10326    | size of the data in the raw file }}
{{OBDtr| 0x44 | offset  |C8FFFF| 20 10 59 00 | 0x591020  | at this position starts the part in the raw file }}
{{OBDtr| 0x44 | offset  |C8FFFF| 20 10 59 00 | 0x591020  | offset of the data in the raw file }}
{{OBDtr| 0x48 | char[24] |FFC8FF| AD DE      | dead      | 24 unused bytes (padding) }}
{{OBDtr| 0x48 | char[24] |FFC8FF| AD DE      | dead      | 24 unused bytes (padding) }}
|}
|}
Line 129: Line 129:
:The 24 bytes at the end are ''not'' part of the SNDD template. They are not loaded by the Oni engine.
:The 24 bytes at the end are ''not'' part of the SNDD template. They are not loaded by the Oni engine.
;Duration
;Duration
:Same as for Windows demo and Mac, the duration (number of game ticks) is rounded to the ''lower'' value (a.k.a. "floor") in Vanilla Oni data.<ref name="ticks"/> In other words, it indicates the number of ''complete'' game ticks spanned by the sound's playback.
:Same as for Windows demo and Mac, the duration (number of game ticks) is rounded to the ''lower'' value (a.k.a. "floor") in vanilla Oni data.<ref name="ticks"/> In other words, it indicates the number of ''complete'' game ticks spanned by the sound's playback.
;Compression modes (flags)
;Compression modes (flags)
:Unlike for Windows demo, there is no single compressed/uncompressed flag in Windows retail SNDDs, and no stereo/mono flag either.
:Unlike for Windows demo, there is no single compressed/uncompressed flag in Windows retail SNDDs, and no stereo/mono flag either.
:The '''channel count''' is specified in the 50-byte header if said header is enabled, otherwise it is inferred from [[OBD:OSBD/OSGr|OSGr]].
:The '''channel count''' is specified in the 50-byte header if said header is enabled, otherwise it is inferred from [[OBD:OSBD/OSGr|OSGr]].
:As for '''compression''', Windows retail actually has ''three'' primary compression modes, commanded by the flag values. Only the first is used in Vanilla Oni.
:As for '''compression''', Windows retail actually has ''three'' primary compression modes, commanded by the flag values. Only the first is used in vanilla Oni.


===WAVE-like format header ("8" flag)===
===WAVE-like format header ("8" flag)===
If the "8" flag of the SNDD (at 0x08) is ON and the "4" flag is OFF (as is always the case in Vanilla Oni), the 50-byte block is interpreted as a standard "fmt " chunk that you find in WAVE files (see [[/wav|HERE]] for details).
If the "8" flag of the SNDD (at 0x08) is ON and the "4" flag is OFF (as is always the case in vanilla Oni), the 50-byte block is interpreted as a standard "fmt " chunk that you find in WAVE files (see [[/wav|HERE]] for details).


[[Image:sndd_hd.gif]]
[[Image:sndd_hd.gif]]
Line 143: Line 143:
{{OBDth}}
{{OBDth}}
{{OBDtr| 0x0C | int16    |FFFFC8| 02 00      | 2    | format ID (2 {{=}} MS ADPCM format)
{{OBDtr| 0x0C | int16    |FFFFC8| 02 00      | 2    | format ID (2 {{=}} MS ADPCM format)
:<small>'''N.B.''' At the time of writing, only "1" (linear PCM) and "2" (MS ADPCM) are known to work in Oni; in Vanilla Oni, only MS ADPCM is ever used.</small>}}
:<small>'''N.B.''' At the time of writing, only "1" (linear PCM) and "2" (MS ADPCM) are known to work in Oni; in vanilla Oni, only MS ADPCM is ever used.</small>}}
{{OBDtr| 0x0E | int16    |C8FFC8| 01 00      | 1    | number of channels (1 {{=}} mono)
{{OBDtr| 0x0E | int16    |C8FFC8| 01 00      | 1    | number of channels (1 {{=}} mono)
:<small>'''N.B.''' Both PCM and ADPCM support only mono and stereo sounds, i.e., 1 or 2 channels.</small>}}
:<small>'''N.B.''' Both PCM and ADPCM support only mono and stereo sounds, i.e., 1 or 2 channels.</small>}}
Line 152: Line 152:
{{OBDtr| 0x18 | int16    |FFC800| 02 00      | 512  | block alignment a.k.a. "block size", in bytes
{{OBDtr| 0x18 | int16    |FFC800| 02 00      | 512  | block alignment a.k.a. "block size", in bytes
:<small>'''N.B.''' The block size is trivially 2 bytes for PCM mono (one 16-bit sample) and 4 bytes for PCM stereo (Left and Right 16-bit samples).</small>
:<small>'''N.B.''' The block size is trivially 2 bytes for PCM mono (one 16-bit sample) and 4 bytes for PCM stereo (Left and Right 16-bit samples).</small>
:<small>'''N.B.''' For ADPCM, Oni's Vanilla data always uses 512 bytes per channel for 22050 Hz waveforms, and 1024 bytes for 44.1 kHz mono (see below).}}
:<small>'''N.B.''' For ADPCM, Oni's vanilla data always uses 512 bytes per channel for 22050 Hz waveforms, and 1024 bytes for 44.1 kHz mono (see below).}}
{{OBDtr| 0x1A | int16    |C800C8| 04 00      | 4    | bits per sample (per channel); typically 4 bits for ADPCM, 16 bits for PCM }}
{{OBDtr| 0x1A | int16    |C800C8| 04 00      | 4    | bits per sample (per channel); typically 4 bits for ADPCM, 16 bits for PCM }}
{{OBDtrBK|1=Special extended ADPCM wav format header (black outline); fully ignored if the format ID is 1 }}
{{OBDtrBK|1=Special extended ADPCM wav format header (black outline); fully ignored if the format ID is 1 }}
Line 183: Line 183:
|}
|}
;PCM vs ADPCM
;PCM vs ADPCM
:Although Vanilla Oni SNDDs only ever use MS ADPCM waveforms, some mods have successfully used the (bloated!!!) PCM format.
:Although vanilla Oni SNDDs only ever use MS ADPCM waveforms, some mods have successfully used the (bloated!!!) PCM format.
:For PCM, the format ID (at 0x0C) is set to 1, the block size is either 2 or 4, the data rate formula is simplified, and everything between 0x1C and 0x3E is ignored.   
:For PCM, the format ID (at 0x0C) is set to 1, the block size is either 2 or 4, the data rate formula is simplified, and everything between 0x1C and 0x3E is ignored.   
:See [[/wav#PCM_.28with_.22fmt_.22.29|HERE]] for more details on the importing procedure, but keep in mind that PCM waveforms are ''not'' recommended!
:See [[/wav#PCM_.28with_.22fmt_.22.29|HERE]] for more details on the importing procedure, but keep in mind that PCM waveforms are ''not'' recommended!
Line 191: Line 191:
:Thus, even though these numbers are practically always the same, they are required; don't ever mess with them.  
:Thus, even though these numbers are practically always the same, they are required; don't ever mess with them.  
;Standard sets of ADPCM parameters
;Standard sets of ADPCM parameters
Below are the three types of headers occurring for Vanilla Oni's sounds (MS ADPCM).
Below are the three types of headers occurring for vanilla Oni's sounds (MS ADPCM).
----
----
22.05 kHz mono (used for the vast majority of sounds):
22.05 kHz mono (used for the vast majority of sounds):
Line 499: Line 499:
==Known data issues==
==Known data issues==
;Windows SNDD data
;Windows SNDD data
:The MS ADPCM data used by Vanilla Oni on Windows (both retail and demo) is somewhat coarser (lossier) than the IMA4 ADPCM used on Mac. This is because of the much larger block size, and how the same predictor must be used for the whole block: whenever a block spans both high- and low-amplitude samples, the predictor adapts to the higher amplitudes, and the low-amplitude resolution is lost.
:The MS ADPCM data used by vanilla Oni on Windows (both retail and demo) is somewhat coarser (lossier) than the IMA4 ADPCM used on Mac. This is because of the much larger block size, and how the same predictor must be used for the whole block: whenever a block spans both high- and low-amplitude samples, the predictor adapts to the higher amplitudes, and the low-amplitude resolution is lost.
:As a minor issue, the lack of an exact sample count (similar to a WAVE's "fact") makes it impossible to specify an odd number of samples for a mono block (because there is no way to tell if the last byte's second nibble counts as data or not). It is also impossible to have only one sample in the last block, be it for mono or stereo (because the block header reads as two samples by default).
:As a minor issue, the lack of an exact sample count (similar to a WAVE's "fact") makes it impossible to specify an odd number of samples for a mono block (because there is no way to tell if the last byte's second nibble counts as data or not). It is also impossible to have only one sample in the last block, be it for mono or stereo (because the block header reads as two samples by default).