vgmstream/src/meta/gcsw.c

46 lines
1.2 KiB
C
Raw Normal View History

#include "meta.h"
2019-07-28 15:11:17 +02:00
/* GCSW - from Radirgy GeneriC (GC) */
VGMSTREAM * init_vgmstream_gcsw(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
2019-07-28 15:11:17 +02:00
int channel_count, loop_flag;
off_t start_offset;
2019-07-28 15:11:17 +02:00
/* checks */
if (!check_extensions(streamFile, "gcw"))
goto fail;
2019-07-28 15:11:17 +02:00
if (read_32bitBE(0,streamFile) != 0x47435357) /* "GCSW" */
goto fail;
2019-07-28 15:11:17 +02:00
start_offset = 0x20;
channel_count = read_32bitBE(0x0c,streamFile);
loop_flag = read_32bitBE(0x1c,streamFile);
2019-07-28 15:11:17 +02:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
2019-07-28 15:11:17 +02:00
vgmstream->meta_type = meta_GCSW;
vgmstream->sample_rate = read_32bitBE(0x08,streamFile);
vgmstream->num_samples = read_32bitBE(0x10,streamFile);
vgmstream->loop_start_sample = read_32bitBE(0x14,streamFile);
vgmstream->loop_end_sample = read_32bitBE(0x18,streamFile);
vgmstream->coding_type = coding_PCM16BE;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x8000;
2019-07-28 15:11:17 +02:00
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream;
fail:
2019-07-28 15:11:17 +02:00
close_vgmstream(vgmstream);
return NULL;
}