vgmstream/src/meta/sat_sap.c

47 lines
1.2 KiB
C
Raw Normal View History

#include "meta.h"
#include "../util.h"
2019-10-05 14:51:49 +02:00
/* SAP - from Bubble Symphony (SAT) */
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;
2019-10-05 14:51:49 +02:00
/* checks */
if (!check_extensions(streamFile, "sap"))
goto fail;
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 */
2019-10-05 14:51:49 +02:00
if (read_32bitBE(0x08,streamFile) != 0x10) /* bps? */
goto fail;
if (read_16bitBE(0x0c,streamFile) != 0x400E) /* ? */
goto fail;
2019-10-05 14:51:49 +02:00
loop_flag = 0;
start_offset = 0x800;
2019-10-05 14:51:49 +02:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
2019-10-05 14:51:49 +02:00
vgmstream->meta_type = meta_SAP;
vgmstream->sample_rate = (uint16_t)read_16bitBE(0x0E,streamFile);
2019-10-05 14:51:49 +02:00
vgmstream->num_samples = num_samples;
2019-10-05 14:51:49 +02:00
vgmstream->coding_type = coding_PCM16BE;
vgmstream->layout_type = layout_none;
2019-10-05 14:51:49 +02:00
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream;
fail:
2019-10-05 14:51:49 +02:00
close_vgmstream(vgmstream);
return NULL;
}