diff --git a/src/formats.c b/src/formats.c index 9a7fb7cb..9c11fe4a 100644 --- a/src/formats.c +++ b/src/formats.c @@ -31,6 +31,7 @@ static const char* extension_list[] = { "adm", "adp", "adpcm", + "adpcmx", "ads", "adw", "adx", @@ -272,6 +273,7 @@ static const char* extension_list[] = { "oma", //FFmpeg/not parsed (ATRAC3/ATRAC3PLUS/MP3/LPCM/WMA) "omu", //"opus", //common + "opusx", "otm", "ovb", @@ -1120,6 +1122,7 @@ static const meta_info meta_info_list[] = { {meta_MSF_TAMASOFT, "Tama-Soft MSF header"}, {meta_XPS_DAT, "From Software .XPS+DAT header"}, {meta_ZSND, "Vicarious Visions ZSND header"}, + {meta_DSP_ADPCMX, "AQUASTYLE ADPY header"}, }; diff --git a/src/meta/meta.h b/src/meta/meta.h index 4cb26957..0c60aef8 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -48,6 +48,7 @@ VGMSTREAM * init_vgmstream_dsp_mcadpcm(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_dsp_switch_audio(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_dsp_sps_n1(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_dsp_itl_ch(STREAMFILE *streamFile); +VGMSTREAM * init_vgmstream_dsp_adpcmx(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_csmp(STREAMFILE *streamFile); @@ -663,6 +664,7 @@ VGMSTREAM * init_vgmstream_opus_shinen(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_nus3(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_sps_n1(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_nxa(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_opus_opusx(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_pc_al2(STREAMFILE * streamFile); diff --git a/src/meta/ngc_dsp_std.c b/src/meta/ngc_dsp_std.c index 9eaf8071..010287e1 100644 --- a/src/meta/ngc_dsp_std.c +++ b/src/meta/ngc_dsp_std.c @@ -1115,7 +1115,7 @@ fail: } /* .vag - Nippon Ichi SPS wrapper [Penny-Punching Princess (Switch), Ys VIII (Switch)] */ -VGMSTREAM * init_vgmstream_dsp_sps_n1(STREAMFILE *streamFile) {//todo rename +VGMSTREAM * init_vgmstream_dsp_sps_n1(STREAMFILE *streamFile) { dsp_meta dspm = {0}; /* checks */ @@ -1168,3 +1168,31 @@ VGMSTREAM * init_vgmstream_dsp_itl_ch(STREAMFILE *streamFile) { fail: return NULL; } + +/* .adpcmx - AQUASTYLE wrapper [Touhou Genso Wanderer -Reloaded- (Switch)] */ +VGMSTREAM * init_vgmstream_dsp_adpcmx(STREAMFILE *streamFile) { + dsp_meta dspm = {0}; + + /* checks */ + if (!check_extensions(streamFile, "adpcmx")) + goto fail; + if (read_32bitBE(0x00,streamFile) != 0x41445059) /* "ADPY" */ + goto fail; + /* 0x04(2): 1? */ + /* 0x08: some size? */ + /* 0x0c: null */ + + dspm.channel_count = read_16bitLE(0x06,streamFile); + dspm.max_channels = 2; + dspm.little_endian = 1; + + dspm.header_offset = 0x10; + dspm.header_spacing = 0x60; + dspm.start_offset = dspm.header_offset + dspm.header_spacing*dspm.channel_count; + dspm.interleave = 0x08; + + dspm.meta_type = meta_DSP_ADPCMX; + return init_vgmstream_dsp_common(streamFile, &dspm); +fail: + return NULL; +} diff --git a/src/meta/opus.c b/src/meta/opus.c index 8a9c60b5..21186b88 100644 --- a/src/meta/opus.c +++ b/src/meta/opus.c @@ -57,7 +57,6 @@ static VGMSTREAM * init_vgmstream_opus(STREAMFILE *streamFile, meta_t meta_type, goto fail; #endif - /* open the file for reading */ if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) goto fail; return vgmstream; @@ -308,3 +307,36 @@ VGMSTREAM * init_vgmstream_opus_sps_n1(STREAMFILE *streamFile) { fail: return NULL; } + +/* AQUASTYLE wrapper [Touhou Genso Wanderer -Reloaded- (Switch)] */ +VGMSTREAM * init_vgmstream_opus_opusx(STREAMFILE *streamFile) { + off_t offset; + int num_samples, loop_start = 0, loop_end = 0; + float modifier; + + /* checks */ + if (!check_extensions(streamFile, "opusx")) + goto fail; + if (read_32bitBE(0x00, streamFile) != 0x4F505553) /* "OPUS" */ + goto fail; + + offset = 0x10; + /* values are for the original 44100 files, but Opus resamples to 48000 */ + modifier = 48000.0f / 44100.0f; + num_samples = 0;//read_32bitLE(0x04, streamFile) * modifier; /* better use calc'd num_samples */ + loop_start = read_32bitLE(0x08, streamFile) * modifier; + loop_end = read_32bitLE(0x0c, streamFile) * modifier; + + /* resampling calcs are slighly off and may to over num_samples, but by removing delay seems ok */ + if (loop_start >= 120) { + loop_start -= 128; + loop_end -= 128; + } + else { + loop_end = 0; + } + + return init_vgmstream_opus(streamFile, meta_OPUS, offset, num_samples, loop_start, loop_end); +fail: + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 6610e111..e470398f 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -453,6 +453,8 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_xps_dat, init_vgmstream_xps, init_vgmstream_zsnd, + init_vgmstream_opus_opusx, + init_vgmstream_dsp_adpcmx, /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */ diff --git a/src/vgmstream.h b/src/vgmstream.h index 17c8d61d..d8881415 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -708,6 +708,7 @@ typedef enum { meta_MSF_TAMASOFT, meta_XPS_DAT, meta_ZSND, + meta_DSP_ADPCMX } meta_t;