2018-01-27 12:21:25 +01:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../coding/coding.h"
|
|
|
|
|
2018-10-07 23:59:42 +02:00
|
|
|
/* .SPS - Nippon Ichi wrapper [ClaDun (PSP)] */
|
2018-01-27 12:21:25 +01:00
|
|
|
VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM *vgmstream = NULL;
|
|
|
|
STREAMFILE *temp_streamFile = NULL;
|
|
|
|
int type, sample_rate;
|
|
|
|
off_t subfile_offset;
|
|
|
|
size_t subfile_size;
|
|
|
|
|
|
|
|
/* check extensions */
|
|
|
|
if ( !check_extensions(streamFile,"sps"))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* mini header */
|
2018-10-07 23:59:42 +02:00
|
|
|
type = read_32bitLE(0x00,streamFile);
|
2018-01-27 12:21:25 +01:00
|
|
|
subfile_size = read_32bitLE(0x04,streamFile);
|
|
|
|
sample_rate = (uint16_t)read_16bitLE(0x08,streamFile);
|
2018-10-07 23:59:42 +02:00
|
|
|
/* 0x0a: flag? */
|
2018-01-27 12:21:25 +01:00
|
|
|
//num_samples = read_32bitLE(0x0c,streamFile);
|
|
|
|
subfile_offset = 0x10;
|
|
|
|
|
|
|
|
/* init the VGMSTREAM */
|
|
|
|
switch(type) {
|
|
|
|
case 1: /* .vag */
|
2018-10-27 23:49:08 +02:00
|
|
|
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset, subfile_size, "vag");
|
2018-01-27 12:21:25 +01:00
|
|
|
if (!temp_streamFile) goto fail;
|
|
|
|
|
2018-08-21 22:16:56 +02:00
|
|
|
vgmstream = init_vgmstream_vag(temp_streamFile);
|
2018-01-27 12:21:25 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* .at3 */
|
2018-10-27 23:49:08 +02:00
|
|
|
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset, subfile_size, "at3");
|
2018-01-27 12:21:25 +01:00
|
|
|
if (!temp_streamFile) goto fail;
|
2018-01-27 12:24:35 +01:00
|
|
|
|
2018-01-27 12:21:25 +01:00
|
|
|
vgmstream = init_vgmstream_riff(temp_streamFile);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->sample_rate = sample_rate; /* .vag header doesn't match */
|
|
|
|
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_streamfile(temp_streamFile);
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|