Fix some dual .adp [Tale of Despereaux (Wii)]

This commit is contained in:
bnnm 2022-12-07 21:30:29 +01:00
parent 4cbffd0c68
commit 32451ed096

View File

@ -11,8 +11,8 @@ struct dsp_header {
uint32_t sample_rate; /* 0x08 (generally 22/32/44/48kz but games like Wario World set 32028hz to adjust for GC's rate) */
uint16_t loop_flag; /* 0x0c */
uint16_t format; /* 0x0e (always 0 for ADPCM) */
uint32_t loop_start_offset; /* 0x10 */
uint32_t loop_end_offset; /* 0x14 */
uint32_t loop_start_offset; /* 0x10 (in nibbles, should be 2 if 0/not set) */
uint32_t loop_end_offset; /* 0x14 (in nibbles) */
uint32_t initial_offset; /* 0x18 ("ca", in nibbles, should be 2) */
int16_t coef[16]; /* 0x1c (eight pairs) */
uint16_t gain; /* 0x3c (always 0 for ADPCM) */
@ -291,7 +291,7 @@ fail:
/* ********************************* */
/* .dsp - standard dsp as generated by DSPADPCM.exe */
/* .dsp - standard mono dsp as generated by DSPADPCM.exe */
VGMSTREAM* init_vgmstream_ngc_dsp_std(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
struct dsp_header header;
@ -304,7 +304,7 @@ VGMSTREAM* init_vgmstream_ngc_dsp_std(STREAMFILE* sf) {
goto fail;
/* .dsp: standard
* .adp: Dr. Muto/Battalion Wars (GC) mono files
* .adp: Dr. Muto/Battalion Wars (GC), Tale of Despereaux (Wii)
* (extensionless): Tony Hawk's Downhill Jam (Wii) */
if (!check_extensions(sf, "dsp,adp,"))
goto fail;
@ -319,7 +319,8 @@ VGMSTREAM* init_vgmstream_ngc_dsp_std(STREAMFILE* sf) {
* out thoroughly, we're probably not dealing with a genuine mono DSP.
* In many cases these will pass all the other checks, including the
* predictor/scale check if the first byte is 0 */
//todo maybe this meta should be after others, so they have a chance to detect >1ch .dsp
//TODO: maybe this meta should be after others, so they have a better chance to detect >1ch .dsp
// (but .dsp is the common case, so it'd be slower)
{
int ko;
struct dsp_header header2;
@ -344,6 +345,21 @@ VGMSTREAM* init_vgmstream_ngc_dsp_std(STREAMFILE* sf) {
header.loop_flag == header2.loop_flag) {
goto fail;
}
/* ignore ddsp, that set samples/nibbles counting both channels so can't be detected
* (could check for .dsp but most files don't need this) */
if (check_extensions(sf, "adp")) {
uint32_t interleave = (get_streamfile_size(sf) / 2);
ko = !read_dsp_header_be(&header2, interleave, sf);
if (!ko &&
header.sample_count == header2.sample_count &&
header.nibble_count == header2.nibble_count &&
header.sample_rate == header2.sample_rate &&
header.loop_flag == header2.loop_flag) {
goto fail;
}
}
}
if (header.loop_flag) {
@ -822,14 +838,15 @@ fail:
return NULL;
}
/* .ddsp - full interleaved dsp [Shark Tale, (GC), The Sims 2: Pets (Wii), Wacky Races: Crash & Dash (Wii)] */
/* .ddsp - full interleaved dsp [Shark Tale (GC), The Sims 2: Pets (Wii), Wacky Races: Crash & Dash (Wii)] */
VGMSTREAM* init_vgmstream_dsp_ddsp(STREAMFILE* sf) {
dsp_meta dspm = {0};
/* checks */
/* .ddsp: assumed?
/* .adp: Tale of Despereaux (Wii) */
/* .ddsp: fake extension (games have bigfiles without names, but has references to .wav)
* .wav: Wacky Races: Crash & Dash (Wii) */
if (!check_extensions(sf, "ddsp,wav,lwav"))
if (!check_extensions(sf, "adp,ddsp,wav,lwav"))
goto fail;
dspm.channels = 2;
@ -840,6 +857,9 @@ VGMSTREAM* init_vgmstream_dsp_ddsp(STREAMFILE* sf) {
dspm.start_offset = 0x60;
dspm.interleave = dspm.header_spacing;
/* this format has nibbles in both headers matching all data (not just for that channel),
* and interleave is exact half even for files that aren't aligned to 0x10 */
dspm.meta_type = meta_DSP_DDSP;
return init_vgmstream_dsp_common(sf, &dspm);
fail: