mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Fix MUSC looping [Spyro: A New Beginning (PS2), Ty (PS2)]
This commit is contained in:
parent
1da9d0887a
commit
cb64f71ba0
@ -639,9 +639,9 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_FSB4, "FMOD Sample Bank (FSB4) Header"},
|
{meta_FSB4, "FMOD Sample Bank (FSB4) Header"},
|
||||||
{meta_FSB5, "FMOD Sample Bank (FSB5) Header"},
|
{meta_FSB5, "FMOD Sample Bank (FSB5) Header"},
|
||||||
{meta_RWX, "RWX Header"},
|
{meta_RWX, "RWX Header"},
|
||||||
{meta_XWB, "Microsoft XWB Header"},
|
{meta_XWB, "Microsoft XWB header"},
|
||||||
{meta_PS2_XA30, "Reflections XA30 PS2 header"},
|
{meta_PS2_XA30, "Reflections XA30 PS2 header"},
|
||||||
{meta_MUSC, "MUSC Header"},
|
{meta_MUSC, "Krome MUSC header"},
|
||||||
{meta_MUSX_V004, "MUSX / Version 004 Header"},
|
{meta_MUSX_V004, "MUSX / Version 004 Header"},
|
||||||
{meta_MUSX_V005, "MUSX / Version 005 Header"},
|
{meta_MUSX_V005, "MUSX / Version 005 Header"},
|
||||||
{meta_MUSX_V006, "MUSX / Version 006 Header"},
|
{meta_MUSX_V006, "MUSX / Version 006 Header"},
|
||||||
|
@ -1,73 +1,50 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
#include "../coding/coding.h"
|
||||||
|
#include "../layout/layout.h"
|
||||||
|
|
||||||
/* MUSC (near all Spyro games and many other using this) */
|
/* MUSC - from Krome's PS2 games (The Legend of Spyro, Ty the Tasmanian Tiger) */
|
||||||
VGMSTREAM * init_vgmstream_musc(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_musc(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[PATH_LIMIT];
|
int loop_flag, channel_count;
|
||||||
int loop_flag;
|
|
||||||
int channel_count;
|
|
||||||
off_t start_offset;
|
off_t start_offset;
|
||||||
|
size_t data_size;
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* .mus is the real extension, .musc is the header ID */
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
if (!check_extensions(streamFile,"mus,musc"))
|
||||||
if (strcasecmp("mus",filename_extension(filename)) &&
|
goto fail;
|
||||||
strcasecmp("musc",filename_extension(filename)))
|
if (read_32bitBE(0x00,streamFile) != 0x4D555343) /* "MUSC" */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* check header */
|
|
||||||
if (read_32bitBE(0x0,streamFile) != 0x4D555343) /* MUSC */
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* check file size */
|
|
||||||
if ((read_32bitLE(0x10,streamFile)+read_32bitLE(0x14,streamFile)) != (get_streamfile_size(streamFile)))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
loop_flag = 0;
|
|
||||||
channel_count = 2;
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
||||||
if (!vgmstream) goto fail;
|
|
||||||
|
|
||||||
start_offset = read_32bitLE(0x10,streamFile);
|
start_offset = read_32bitLE(0x10,streamFile);
|
||||||
vgmstream->coding_type = coding_PSX;
|
data_size = read_32bitLE(0x14,streamFile);
|
||||||
vgmstream->channels = channel_count;
|
if (start_offset + data_size != get_streamfile_size(streamFile))
|
||||||
vgmstream->sample_rate = (uint16_t) read_16bitLE(0x06,streamFile);
|
goto fail;
|
||||||
|
/* always does full loops unless it ends in silence */
|
||||||
vgmstream->num_samples = read_32bitLE(0x14,streamFile)/channel_count/16*28;
|
loop_flag = read_32bitBE(get_streamfile_size(streamFile) - 0x10,streamFile) != 0x0C000000;
|
||||||
|
channel_count = 2;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (loop_flag)
|
|
||||||
{
|
|
||||||
vgmstream->loop_start_sample = 0;
|
|
||||||
vgmstream->loop_end_sample = (read_32bitLE(0x14,streamFile))*28/16/channel_count;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vgmstream->layout_type = layout_interleave;
|
/* build the VGMSTREAM */
|
||||||
vgmstream->interleave_block_size = read_32bitLE(0x18,streamFile)/2;
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
vgmstream->meta_type = meta_MUSC;
|
vgmstream->meta_type = meta_MUSC;
|
||||||
|
vgmstream->coding_type = coding_PSX;
|
||||||
|
vgmstream->layout_type = layout_interleave;
|
||||||
|
vgmstream->interleave_block_size = read_32bitLE(0x18,streamFile) / 2;
|
||||||
|
|
||||||
/* open the file for reading */
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||||
{
|
goto fail;
|
||||||
int i;
|
|
||||||
STREAMFILE * file;
|
|
||||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
if (!file) goto fail;
|
|
||||||
for (i=0;i<channel_count;i++) {
|
|
||||||
vgmstream->ch[i].streamfile = file;
|
|
||||||
|
|
||||||
vgmstream->ch[i].channel_start_offset=
|
|
||||||
vgmstream->ch[i].offset=start_offset+
|
|
||||||
vgmstream->interleave_block_size*i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
/* clean up anything we may have opened */
|
|
||||||
fail:
|
fail:
|
||||||
if (vgmstream) close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user