From 58734480a6f90319eecb1fca7959d449a19775b9 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 28 Jul 2019 23:34:08 +0200 Subject: [PATCH 1/3] Fix check --- src/meta/awb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meta/awb.c b/src/meta/awb.c index 6f80d553..9d21b09f 100644 --- a/src/meta/awb.c +++ b/src/meta/awb.c @@ -83,7 +83,7 @@ VGMSTREAM * init_vgmstream_awb_memory(STREAMFILE *streamFile, STREAMFILE *acbFil subfile_size = subfile_next - subfile_offset; } - ;VGM_LOG("AWB: subfile offset=%lx + %x\n", subfile_offset, subfile_size); + //;VGM_LOG("AWB: subfile offset=%lx + %x\n", subfile_offset, subfile_size); /* autodetect as there isn't anything, plus can mix types * (waveid<>codec info is usually in the companion .acb) */ @@ -109,7 +109,7 @@ VGMSTREAM * init_vgmstream_awb_memory(STREAMFILE *streamFile, STREAMFILE *acbFil } else if (read_u32be(subfile_offset + 0x08,streamFile) >= 8000 && read_u32be(subfile_offset + 0x08,streamFile) <= 48000 && - read_u16be(subfile_offset + 0x08,streamFile) == 0 && + read_u16be(subfile_offset + 0x0e,streamFile) == 0 && read_u32be(subfile_offset + 0x18,streamFile) == 2 && read_u32be(subfile_offset + 0x50,streamFile) == 0) { /* probably should call some check function (type 13) */ type = DSP; From 02a11d447bd0148d62d525070971a2e1cff230b3 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 28 Jul 2019 23:34:55 +0200 Subject: [PATCH 2/3] Add Switch .xnb [Eagle Island (Switch)] --- src/meta/xnb.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/meta/xnb.c b/src/meta/xnb.c index 384a17f8..d642206b 100644 --- a/src/meta/xnb.c +++ b/src/meta/xnb.c @@ -18,7 +18,7 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) { goto fail; /* XNA Studio platforms: 'w' = Windows, 'm' = Windows Phone 7, 'x' = X360 - * MonoGame extensions: 'i' = iOS, 'a' = Android, 'X' = MacOSX, 'P': PS4, etc */ + * MonoGame extensions: 'i' = iOS, 'a' = Android, 'X' = MacOSX, 'P' = PS4, 'S' = Switch, etc */ platform = read_8bit(0x03,streamFile); big_endian = (platform == 'x'); @@ -58,7 +58,7 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) { if ( strcmp(reader_name, type_sound) != 0 ) goto fail; current_offset += reader_string_len + 1; - current_offset += 4; /* reader version */ + current_offset += 0x04; /* reader version */ /* shared resource count */ if (read_8bit(current_offset++, streamFile) != 1) @@ -66,13 +66,13 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) { /* shared resource: partial "fmt" chunk */ fmt_chunk_size = read_32bitLE(current_offset, streamFile); - current_offset += 4; + current_offset += 0x04; { int32_t (*read_32bit)(off_t,STREAMFILE*) = big_endian ? read_32bitBE : read_32bitLE; int16_t (*read_16bit)(off_t,STREAMFILE*) = big_endian ? read_16bitBE : read_16bitLE; - codec = read_16bit(current_offset+0x00, streamFile); + codec = (uint16_t)read_16bit(current_offset+0x00, streamFile); channel_count = read_16bit(current_offset+0x02, streamFile); sample_rate = read_32bit(current_offset+0x04, streamFile); /* 0x08: byte rate */ @@ -83,12 +83,17 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) { xma2_parse_fmt_chunk_extra(streamFile, current_offset, &loop_flag, &num_samples, &loop_start, &loop_end, big_endian); xma_chunk_offset = current_offset; } + + if (codec == 0xFFFF) { + if (platform != 'S') goto fail; + sample_rate = read_32bit(current_offset+fmt_chunk_size+0x04+0x08, streamFile); + } } current_offset += fmt_chunk_size; data_size = read_32bitLE(current_offset, streamFile); - current_offset += 4; + current_offset += 0x04; start_offset = current_offset; } @@ -151,6 +156,16 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) { break; } #endif + case 0xFFFF: /* Eagle Island (Switch) */ + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = data_size / channel_count; + vgmstream->num_samples = read_32bitLE(start_offset + 0x00, streamFile); + //vgmstream->num_samples = dsp_bytes_to_samples(data_size - 0x60*channel_count, channel_count); + + dsp_read_coefs(vgmstream,streamFile,start_offset + 0x1c,vgmstream->interleave_block_size,big_endian); + dsp_read_hist (vgmstream,streamFile,start_offset + 0x3c,vgmstream->interleave_block_size,big_endian); + break; default: VGM_LOG("XNB: unknown codec 0x%x\n", codec); From 22c7f5e384f2ee2eb378c78ec96525e5a2a80282 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 28 Jul 2019 23:35:21 +0200 Subject: [PATCH 3/3] Fix some DSP .xwb [Skulls of the Shogun (Switch)] --- src/meta/xwb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/meta/xwb.c b/src/meta/xwb.c index 84a26ce8..f60cf6fd 100644 --- a/src/meta/xwb.c +++ b/src/meta/xwb.c @@ -326,8 +326,11 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) { } else if (xwb.version == XACT3_0_MAX && xwb.codec == XMA2 && xwb.bits_per_sample == 0x01 && xwb.block_align == 0x04 - && xwb.data_size == 0x55951c1c) { /* some kind of id? */ - /* Stardew Valley (Switch), full interleaved DSPs (including headers) */ + && read_32bitLE(xwb.stream_offset + 0x08, streamFile) == xwb.sample_rate /* DSP header */ + && read_16bitLE(xwb.stream_offset + 0x0e, streamFile) == 0 + && read_32bitLE(xwb.stream_offset + 0x18, streamFile) == 2 + /*&& xwb.data_size == 0x55951c1c*/) { /* some kind of id in Stardew Valley? */ + /* Stardew Valley (Switch), Skulls of the Shogun (Switch): full interleaved DSPs (including headers) */ xwb.codec = DSP; } else if (xwb.version == XACT3_0_MAX && xwb.codec == XMA2 @@ -342,7 +345,7 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) { xwb.loop_flag = (xwb.loop_end > 0 || xwb.loop_end_sample > xwb.loop_start) && !(xwb.entry_flags & WAVEBANKENTRY_FLAGS_IGNORELOOP); - /* Oddworld OGG the data_size value is size of uncompressed bytes instead; DSP uses some id/config as value */ + /* Oddworld OGG the data_size value is size of uncompressed bytes instead; DSP uses some id/config as value */ if (xwb.codec != OGG && xwb.codec != DSP && xwb.codec != ATRAC9_RIFF) { /* some low-q rips don't remove padding, relax validation a bit */ if (xwb.data_offset + xwb.stream_size > get_streamfile_size(streamFile))