2010-06-08 01:31:49 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
2017-05-18 21:00:42 +02:00
|
|
|
#include "../coding/coding.h"
|
2010-06-08 01:31:49 +02:00
|
|
|
|
2017-05-18 21:00:42 +02:00
|
|
|
/* XAU - XPEC Entertainment sound format (Beat Down PS2/Xbox, Spectral Force Chronicle [SLPM-65967]) */
|
|
|
|
VGMSTREAM * init_vgmstream_xau(STREAMFILE *streamFile) {
|
2010-06-08 01:31:49 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2017-05-18 21:00:42 +02:00
|
|
|
int loop_flag, channel_count, type, loop_start, loop_end;
|
2010-06-08 01:31:49 +02:00
|
|
|
|
|
|
|
|
2017-05-18 21:00:42 +02:00
|
|
|
/* check extension */
|
|
|
|
if (!check_extensions(streamFile, "xau"))
|
|
|
|
goto fail;
|
2010-06-08 01:31:49 +02:00
|
|
|
|
|
|
|
/* check header */
|
2017-05-18 21:00:42 +02:00
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x58415500) /* "XAU\0" "*/
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitLE(0x08,streamFile) != 0x40) /* header start */
|
2010-06-08 01:31:49 +02:00
|
|
|
goto fail;
|
|
|
|
|
2017-05-18 21:00:42 +02:00
|
|
|
/* 0x04: version? (0x100) */
|
|
|
|
type = read_32bitBE(0x0c, streamFile);
|
|
|
|
loop_start = read_32bitLE(0x10, streamFile);
|
|
|
|
loop_end = read_32bitLE(0x14, streamFile);
|
|
|
|
loop_flag = (loop_end > 0);
|
|
|
|
|
2010-06-08 01:31:49 +02:00
|
|
|
channel_count = read_8bit(0x18,streamFile);
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->channels = channel_count;
|
2017-05-18 21:00:42 +02:00
|
|
|
vgmstream->meta_type = meta_XAU;
|
|
|
|
|
|
|
|
/* miniheader over a common header with some tweaks, so we'll simplify parsing */
|
|
|
|
switch(type) {
|
|
|
|
case 0x50533200: /* "PS2\0" */
|
|
|
|
if (read_32bitBE(0x40,streamFile) != 0x56414770) goto fail; /* "VAGp" */
|
|
|
|
|
|
|
|
start_offset = 0x800;
|
|
|
|
vgmstream->sample_rate = read_32bitBE(0x50, streamFile);
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_32bitBE(0x4C,streamFile) * channel_count, channel_count);
|
|
|
|
vgmstream->loop_start_sample = loop_start;
|
|
|
|
vgmstream->loop_end_sample = loop_end;
|
|
|
|
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x8000;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 0x58420000: /* "XB\0\0" */
|
|
|
|
if (read_32bitBE(0x40,streamFile) != 0x52494646) goto fail; /* "RIFF" */
|
|
|
|
|
|
|
|
start_offset = 0x70;
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x58, streamFile);
|
|
|
|
vgmstream->num_samples = ms_ima_bytes_to_samples(read_32bitLE(0x6c, streamFile), read_16bitLE(0x60, streamFile), channel_count);
|
|
|
|
vgmstream->loop_start_sample = loop_start;
|
|
|
|
vgmstream->loop_end_sample = loop_end;
|
|
|
|
/* there is also a "smpl" chunk at the end, same as loop_start/end */
|
|
|
|
|
|
|
|
vgmstream->coding_type = coding_XBOX;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2010-06-08 01:31:49 +02:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-05-18 21:00:42 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2010-06-08 01:31:49 +02:00
|
|
|
return NULL;
|
2014-06-27 06:12:48 +02:00
|
|
|
}
|