2008-08-19 14:25:43 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
/* SAP - from Bubble Symphony (SAT) */
|
2008-08-19 14:25:43 +02:00
|
|
|
VGMSTREAM * init_vgmstream_sat_sap(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2019-10-05 14:51:49 +02:00
|
|
|
int num_samples;
|
|
|
|
int loop_flag = 0, channel_count;
|
2008-08-19 14:25:43 +02:00
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "sap"))
|
|
|
|
goto fail;
|
2008-08-19 14:25:43 +02:00
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
num_samples = read_32bitBE(0x00,streamFile); /* first for I/O reasons */
|
|
|
|
channel_count = read_32bitBE(0x04,streamFile);
|
|
|
|
if (channel_count != 1) goto fail; /* unknown layout */
|
2008-08-19 14:25:43 +02:00
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
if (read_32bitBE(0x08,streamFile) != 0x10) /* bps? */
|
|
|
|
goto fail;
|
|
|
|
if (read_16bitBE(0x0c,streamFile) != 0x400E) /* ? */
|
2008-08-19 14:25:43 +02:00
|
|
|
goto fail;
|
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
loop_flag = 0;
|
|
|
|
start_offset = 0x800;
|
2008-08-19 14:25:43 +02:00
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2008-08-19 14:25:43 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
vgmstream->meta_type = meta_SAP;
|
2008-08-19 14:25:43 +02:00
|
|
|
vgmstream->sample_rate = (uint16_t)read_16bitBE(0x0E,streamFile);
|
2019-10-05 14:51:49 +02:00
|
|
|
vgmstream->num_samples = num_samples;
|
2008-08-19 14:25:43 +02:00
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
vgmstream->coding_type = coding_PCM16BE;
|
2008-08-19 14:25:43 +02:00
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
|
2019-10-05 14:51:49 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-08-19 14:25:43 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2019-10-05 14:51:49 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-08-19 14:25:43 +02:00
|
|
|
return NULL;
|
|
|
|
}
|