Add .opusx/adpcmx [Touhou Genso Wanderer -Reloaded- (Switch)]

This commit is contained in:
bnnm 2018-12-09 01:23:40 +01:00
parent b43bb3aefe
commit 13a7a5382d
6 changed files with 70 additions and 2 deletions

View File

@ -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"},
};

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -708,6 +708,7 @@ typedef enum {
meta_MSF_TAMASOFT,
meta_XPS_DAT,
meta_ZSND,
meta_DSP_ADPCMX
} meta_t;