mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Fix .wvs glitches [Metal Arms (GC)]
This commit is contained in:
parent
c4d8853ff6
commit
ea40d2adda
@ -1019,8 +1019,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_PS2_ENTH, ".enth Header"},
|
||||
{meta_SDT, "High Voltage .sdt header"},
|
||||
{meta_NGC_TYDSP, ".tydsp Header"},
|
||||
{meta_XBOX_WVS, "Metal Arms WVS Header (XBOX)"},
|
||||
{meta_NGC_WVS, "Metal Arms WVS Header (GameCube)"},
|
||||
{meta_WVS, "Swingin' Ape .WVS header"},
|
||||
{meta_XBOX_MATX, "assumed Matrix file by .matx extension"},
|
||||
{meta_DEC, "Falcom DEC RIFF header"},
|
||||
{meta_VS, "Melbourne House .VS header"},
|
||||
|
@ -264,8 +264,8 @@ VGMSTREAM * init_vgmstream_ngc_tydsp(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_capdsp(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_xbox_wvs(STREAMFILE *streamFile);
|
||||
VGMSTREAM * init_vgmstream_ngc_wvs(STREAMFILE *streamFile);
|
||||
VGMSTREAM* init_vgmstream_wvs_xbox(STREAMFILE* sf);
|
||||
VGMSTREAM* init_vgmstream_wvs_ngc(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM * init_vgmstream_dc_str(STREAMFILE *streamFile);
|
||||
VGMSTREAM * init_vgmstream_dc_str_v2(STREAMFILE *streamFile);
|
||||
|
244
src/meta/wvs.c
244
src/meta/wvs.c
@ -1,134 +1,110 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* WVS - found in Metal Arms - Glitch in the System (Xbox) */
|
||||
VGMSTREAM * init_vgmstream_xbox_wvs(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
size_t data_size;
|
||||
|
||||
|
||||
/* check extension */
|
||||
if (!check_extensions(streamFile,"wvs"))
|
||||
goto fail;
|
||||
|
||||
if (read_16bitLE(0x0C,streamFile) != 0x69 && /* codec */
|
||||
read_16bitLE(0x08,streamFile) != 0x4400)
|
||||
goto fail;
|
||||
|
||||
start_offset = 0x20;
|
||||
data_size = read_32bitLE(0x00,streamFile);
|
||||
loop_flag = (read_16bitLE(0x0a,streamFile) == 0x472C); /* loop seems to be like this */
|
||||
channel_count = read_16bitLE(0x0e,streamFile); /* always stereo files */
|
||||
|
||||
if (data_size + start_offset != get_streamfile_size(streamFile))
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
||||
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, vgmstream->channels);
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_XBOX_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_XBOX_WVS;
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
WVS (found in Metal Arms - Glitch in the System)
|
||||
*/
|
||||
VGMSTREAM * init_vgmstream_ngc_wvs(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("wvs",filename_extension(filename))) goto fail;
|
||||
|
||||
if ((read_32bitBE(0x14,streamFile)*read_32bitBE(0x00,streamFile)+0x60)
|
||||
!= (get_streamfile_size(streamFile)))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = read_32bitBE(0x10,streamFile);
|
||||
channel_count = read_32bitBE(0x00,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x60;
|
||||
|
||||
if (channel_count == 1) {
|
||||
vgmstream->sample_rate = 22050;
|
||||
} else if (channel_count == 2) {
|
||||
vgmstream->sample_rate = 44100;
|
||||
}
|
||||
|
||||
vgmstream->channels = channel_count;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/8/channel_count*14; //(read_32bitBE(0x0C,streamFile)-start_offset)/8/channel_count*14;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x10,streamFile)*2)/8/channel_count*14;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x14,streamFile)*2)/8/channel_count*14;
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x0C,streamFile);
|
||||
vgmstream->meta_type = meta_NGC_WVS;
|
||||
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
int i,c;
|
||||
for (c=0;c<channel_count;c++) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[c].adpcm_coef[i] =
|
||||
read_16bitBE(0x18+c*0x20 +i*2,streamFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* .WVS - found in Metal Arms - Glitch in the System (Xbox) */
|
||||
VGMSTREAM* init_vgmstream_wvs_xbox(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channels, sample_rate;
|
||||
size_t data_size;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf,"wvs"))
|
||||
goto fail;
|
||||
|
||||
data_size = read_u32le(0x00,sf);
|
||||
/* 0x04: float seconds (slightly bigger than max num_samples) */
|
||||
sample_rate = read_f32le(0x08,sf);
|
||||
if (read_u16le(0x0c,sf) != 0x0069) /* codec */
|
||||
goto fail;
|
||||
channels = read_s16le(0x0e,sf);
|
||||
sample_rate = read_s32le(0x10,sf);
|
||||
/* 0x10: sample rate (int) */
|
||||
/* 0x14: bitrate */
|
||||
/* 0x18: block size / bps */
|
||||
/* 0x1c: size? / block samples */
|
||||
|
||||
loop_flag = (channels > 1 && sample_rate >= 44100); /* bgm full loops */
|
||||
start_offset = 0x20;
|
||||
|
||||
if (data_size + start_offset != get_streamfile_size(sf))
|
||||
goto fail;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_WVS;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, channels);
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_XBOX_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* .WVS - found in Metal Arms - Glitch in the System (GC) */
|
||||
VGMSTREAM* init_vgmstream_wvs_ngc(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channels, sample_rate, interleave;
|
||||
size_t data_size;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf,"wvs"))
|
||||
goto fail;
|
||||
|
||||
channels = read_s32be(0x00,sf);
|
||||
/* 0x04: float seconds (slightly bigger than max num_samples) */
|
||||
sample_rate = read_f32be(0x08,sf);
|
||||
interleave = read_u32be(0x0C,sf); /* even in mono */
|
||||
/* 0x10: number of interleave blocks */
|
||||
data_size = read_s32be(0x14,sf) * channels;
|
||||
|
||||
loop_flag = (channels > 1 && sample_rate >= 44100); /* bgm full loops */
|
||||
start_offset = 0x60;
|
||||
|
||||
if (data_size + start_offset != get_streamfile_size(sf))
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_WVS;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = dsp_bytes_to_samples(data_size, channels);
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
if (interleave)
|
||||
vgmstream->interleave_last_block_size = (data_size % (interleave * channels)) / channels;
|
||||
|
||||
dsp_read_coefs_be(vgmstream, sf, 0x18, 0x20);
|
||||
//dsp_read_hist_be(vgmstream, sf, 0x18 + 0x20*channels, 0x04); /* not seen */
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_aix,
|
||||
init_vgmstream_ngc_tydsp,
|
||||
init_vgmstream_capdsp,
|
||||
init_vgmstream_xbox_wvs,
|
||||
init_vgmstream_ngc_wvs,
|
||||
init_vgmstream_wvs_xbox,
|
||||
init_vgmstream_wvs_ngc,
|
||||
init_vgmstream_dc_str,
|
||||
init_vgmstream_dc_str_v2,
|
||||
init_vgmstream_xbox_matx,
|
||||
|
@ -461,8 +461,7 @@ typedef enum {
|
||||
meta_NGC_DSP_KONAMI, /* Konami DSP header, found in various games */
|
||||
meta_UBI_CKD, /* Ubisoft CKD RIFF header (Rayman Origins Wii) */
|
||||
meta_RAW_WAVM,
|
||||
meta_XBOX_WVS, /* XBOX WVS */
|
||||
meta_NGC_WVS, /* Metal Arms - Glitch in the System */
|
||||
meta_WVS,
|
||||
meta_XBOX_MATX, /* XBOX MATX */
|
||||
meta_XMU,
|
||||
meta_XVAS,
|
||||
|
Loading…
Reference in New Issue
Block a user