2010-05-02 21:16:35 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
2017-10-08 17:30:56 +02:00
|
|
|
#include "../coding/coding.h"
|
|
|
|
#include "../layout/layout.h"
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
/* MUSC - from Krome's PS2 games (The Legend of Spyro, Ty the Tasmanian Tiger) */
|
2010-05-02 21:16:35 +02:00
|
|
|
VGMSTREAM * init_vgmstream_musc(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2017-10-08 17:30:56 +02:00
|
|
|
int loop_flag, channel_count;
|
2010-05-02 21:16:35 +02:00
|
|
|
off_t start_offset;
|
2017-10-08 17:30:56 +02:00
|
|
|
size_t data_size;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
/* .mus is the real extension, .musc is the header ID */
|
|
|
|
if (!check_extensions(streamFile,"mus,musc"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x4D555343) /* "MUSC" */
|
|
|
|
goto fail;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
start_offset = read_32bitLE(0x10,streamFile);
|
|
|
|
data_size = read_32bitLE(0x14,streamFile);
|
|
|
|
if (start_offset + data_size != get_streamfile_size(streamFile))
|
|
|
|
goto fail;
|
|
|
|
/* always does full loops unless it ends in silence */
|
|
|
|
loop_flag = read_32bitBE(get_streamfile_size(streamFile) - 0x10,streamFile) != 0x0C000000;
|
2010-05-02 21:16:35 +02:00
|
|
|
channel_count = 2;
|
|
|
|
|
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x06,streamFile);
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count);
|
|
|
|
vgmstream->loop_start_sample = 0;
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
vgmstream->meta_type = meta_MUSC;
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0x18,streamFile) / 2;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
2017-10-08 17:30:56 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2010-05-02 21:16:35 +02:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-10-08 17:30:56 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2010-05-02 21:16:35 +02:00
|
|
|
return NULL;
|
2010-05-03 17:52:29 +02:00
|
|
|
}
|