mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-15 02:57:38 +01:00
Fix some MUSX v5 [Predator: Concrete Jungle (Xbox/PS2)]
This commit is contained in:
parent
1c7a944633
commit
619fbf17c5
468
src/meta/musx.c
468
src/meta/musx.c
@ -2,180 +2,163 @@
|
||||
#include "../util.h"
|
||||
|
||||
|
||||
/* MUSX (Version 004) --------------------------------------->*/
|
||||
/* MUSX (Version 004) */
|
||||
VGMSTREAM * init_vgmstream_musx_v004(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("musx",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "musx"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D555358) /* "MUSX" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x04000000) /* "0x04000000" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x04000000)
|
||||
goto fail;
|
||||
|
||||
loop_flag = (read_32bitLE(0x840,streamFile) != 0xFFFFFFFF);
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
switch (read_32bitBE(0x10,streamFile))
|
||||
{
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX; // PS2 ADPCM
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA; // Eurocom DAT4 4-bit IMA ADPCM
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x58425F5F: /* XB__ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 44100;
|
||||
vgmstream->coding_type = coding_DAT4_IMA; // Eurocom DAT4 4-bit IMA ADPCM
|
||||
vgmstream->num_samples = (read_32bitLE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
switch (read_32bitBE(0x10,streamFile)) {
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x58425F5F: /* XB__ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 44100;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitLE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_MUSX_V004;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
/* <--------------------------------------- MUSX (Version 004) */
|
||||
|
||||
|
||||
/* MUSX (Version 005) --------------------------------------->*/
|
||||
/* MUSX (Version 005) [Predator: Concrete Jungle (PS2/Xbox) ] */
|
||||
VGMSTREAM * init_vgmstream_musx_v005(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("musx",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "musx"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D555358) /* "MUSX" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x05000000) /* "0x04000000" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x05000000)
|
||||
goto fail;
|
||||
|
||||
loop_flag = (read_32bitLE(0x840,streamFile) != 0xFFFFFFFF);
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
switch (read_32bitBE(0x10,streamFile))
|
||||
{
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA; // Eurocom DAT4 4-bit IMA ADPCM
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
switch (read_32bitBE(0x10,streamFile)) {
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
case 0x58425F5F: /* XB__ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 44100;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitLE(0x2C,streamFile))/16/channel_count*28;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))/16/channel_count*28;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_MUSX_V005;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
/* <--------------------------------------- MUSX (Version 005) */
|
||||
|
||||
|
||||
|
||||
/* MUSX (Version 006) ---------------------------------------> */
|
||||
/* MUSX (Version 006) */
|
||||
VGMSTREAM * init_vgmstream_musx_v006(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
@ -189,53 +172,48 @@ VGMSTREAM * init_vgmstream_musx_v006(STREAMFILE *streamFile) {
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D555358) /* "MUSX" */
|
||||
goto fail;
|
||||
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x06000000) /* "0x06000000" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
|
||||
loop_flag = (read_32bitLE(0x840,streamFile)!=0xFFFFFFFF);
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
switch (read_32bitBE(0x10,streamFile))
|
||||
{
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
vgmstream->meta_type = meta_MUSX_V006;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))*28/16/channel_count;
|
||||
}
|
||||
break;
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))*28/16/channel_count;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
vgmstream->meta_type = meta_MUSX_V006;
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))*28/16/channel_count;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
switch (read_32bitBE(0x10,streamFile)) {
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
vgmstream->meta_type = meta_MUSX_V006;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x890,streamFile))*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = (read_32bitLE(0x89C,streamFile))*28/16/channel_count;
|
||||
}
|
||||
break;
|
||||
case 0x47435F5F: /* GC__ */
|
||||
start_offset = read_32bitBE(0x28,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
vgmstream->num_samples = (read_32bitBE(0x2C,streamFile))*28/16/channel_count;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
vgmstream->meta_type = meta_MUSX_V006;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x890,streamFile))*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x89C,streamFile))*28/16/channel_count;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
@ -256,24 +234,21 @@ VGMSTREAM * init_vgmstream_musx_v006(STREAMFILE *streamFile) {
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
/* <--------------------------------------- MUSX (Version 006) */
|
||||
|
||||
|
||||
/* MUSX (Version 010) --------------------------------------->*/
|
||||
/* WII_ in Dead Space: Extraction */
|
||||
/* MUSX (Version 010) [Dead Space: Extraction (Wii), Rio (PS3), Pirates of the Caribbean: At World's End (PSP)] */
|
||||
VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int musx_type; /* determining the decoder by strings like "PS2_", "GC__" and so on */
|
||||
//int musx_version; /* 0x08 provides a "version" byte */
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int musx_type; /* determining the decoder by strings like "PS2_", "GC__" and so on */
|
||||
//int musx_version; /* 0x08 provides a "version" byte */
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
@ -281,17 +256,17 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D555358) /* "MUSX" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
if (read_32bitBE(0x800,streamFile) == 0x53424E4B) /* "SBNK", */ // SoundBank, refuse
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x0A000000) /* "0x0A000000" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
if (read_32bitBE(0x08,streamFile) != 0x0A000000) /* "0x0A000000" */
|
||||
goto fail;
|
||||
|
||||
loop_flag = ((read_32bitLE(0x34,streamFile)!=0x00000000) &&
|
||||
(read_32bitLE(0x34,streamFile)!=0xABABABAB));
|
||||
loop_flag = ((read_32bitLE(0x34,streamFile)!=0x00000000) &&
|
||||
(read_32bitLE(0x34,streamFile)!=0xABABABAB));
|
||||
channel_count = 2;
|
||||
|
||||
musx_type=(read_32bitBE(0x10,streamFile));
|
||||
musx_type=(read_32bitBE(0x10,streamFile));
|
||||
|
||||
if (musx_type == 0x5749495F && /* WII_ */
|
||||
(read_16bitBE(0x40,streamFile) == 0x4441) && /* DA */
|
||||
@ -300,7 +275,7 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
channel_count = read_32bitLE(0x48,streamFile);
|
||||
loop_flag = (read_32bitLE(0x64,streamFile) != -1);
|
||||
}
|
||||
if (musx_type == 0x5053335F && /* PS3_ */
|
||||
if (musx_type == 0x5053335F && /* PS3_ */
|
||||
(read_16bitBE(0x40,streamFile) == 0x4441) && /* DA */
|
||||
(read_8bit(0x42,streamFile) == 0x54)) /* T */
|
||||
{
|
||||
@ -312,11 +287,11 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
loop_flag = 0;
|
||||
}
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
|
||||
/* fill in the vital statistics */
|
||||
switch (musx_type) {
|
||||
case 0x5053325F: /* PS2_ */
|
||||
start_offset = 0x800;
|
||||
@ -351,24 +326,24 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
vgmstream->interleave_block_size = 0x20;
|
||||
vgmstream->meta_type = meta_MUSX_V010;
|
||||
|
||||
if (read_32bitBE(0x40,streamFile)==0x44415438){
|
||||
if (read_32bitBE(0x40,streamFile)==0x44415438){
|
||||
vgmstream->num_samples = read_32bitLE(0x60,streamFile);
|
||||
vgmstream->sample_rate = read_32bitLE(0x4C,streamFile);
|
||||
if (loop_flag)
|
||||
vgmstream->sample_rate = read_32bitLE(0x4C,streamFile);
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x64,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x60,streamFile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
vgmstream->sample_rate = 44100;
|
||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/(0x20)*((0x20-4)*2);
|
||||
if (loop_flag)
|
||||
}
|
||||
else {
|
||||
vgmstream->sample_rate = 44100;
|
||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/(0x20)*((0x20-4)*2);
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x44,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x40,streamFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x5749495F: /* WII_ */
|
||||
start_offset = 0x800;
|
||||
@ -377,7 +352,7 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
switch (read_32bitBE(0x40,streamFile))
|
||||
{
|
||||
case 0x44415434: /* DAT4 */
|
||||
case 0x44415438: /* DAT8 */
|
||||
case 0x44415438: /* DAT8 [GoldenEye 007 (Wii)] */
|
||||
vgmstream->coding_type = coding_DAT4_IMA;
|
||||
break;
|
||||
default:
|
||||
@ -406,7 +381,7 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
@ -426,79 +401,78 @@ VGMSTREAM * init_vgmstream_musx_v010(STREAMFILE *streamFile) {
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
/* <--------------------------------------- MUSX (Version 010) */
|
||||
|
||||
|
||||
/* MUSX (Version 201) --------------------------------------->*/
|
||||
/* MUSX (Version 201) */
|
||||
VGMSTREAM * init_vgmstream_musx_v201(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
//int musx_version; /* 0x08 provides a "version" byte */
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
int loop_detect;
|
||||
int loop_offsets;
|
||||
|
||||
//int musx_version; /* 0x08 provides a "version" byte */
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
int loop_detect;
|
||||
int loop_offsets;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("musx",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4D555358) /* "MUSX" */
|
||||
goto fail;
|
||||
if ((read_32bitBE(0x08,streamFile) != 0xC9000000) &&
|
||||
(read_32bitLE(0x08,streamFile) != 0xC9000000)) /* "0xC9000000" */
|
||||
goto fail;
|
||||
goto fail;
|
||||
if ((read_32bitBE(0x08,streamFile) != 0xC9000000) &&
|
||||
(read_32bitLE(0x08,streamFile) != 0xC9000000)) /* "0xC9000000" */
|
||||
goto fail;
|
||||
|
||||
channel_count = 2;
|
||||
|
||||
loop_detect = read_32bitBE(0x800,streamFile);
|
||||
switch (loop_detect) {
|
||||
case 0x02000000:
|
||||
loop_offsets = 0x8E0;
|
||||
break;
|
||||
case 0x03000000:
|
||||
loop_offsets = 0x880;
|
||||
break;
|
||||
case 0x04000000:
|
||||
loop_offsets = 0x8B4;
|
||||
break;
|
||||
case 0x05000000:
|
||||
loop_offsets = 0x8E8;
|
||||
break;
|
||||
case 0x06000000:
|
||||
loop_offsets = 0x91C;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
loop_detect = read_32bitBE(0x800,streamFile);
|
||||
switch (loop_detect) {
|
||||
case 0x02000000:
|
||||
loop_offsets = 0x8E0;
|
||||
break;
|
||||
case 0x03000000:
|
||||
loop_offsets = 0x880;
|
||||
break;
|
||||
case 0x04000000:
|
||||
loop_offsets = 0x8B4;
|
||||
break;
|
||||
case 0x05000000:
|
||||
loop_offsets = 0x8E8;
|
||||
break;
|
||||
case 0x06000000:
|
||||
loop_offsets = 0x91C;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = (read_32bitLE(loop_offsets+0x04,streamFile) !=0x00000000);
|
||||
loop_flag = (read_32bitLE(loop_offsets+0x04,streamFile) !=0x00000000);
|
||||
start_offset = read_32bitLE(0x18,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = read_32bitLE(0x18,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = read_32bitLE(loop_offsets,streamFile)*28/16/channel_count;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(loop_offsets+0x10,streamFile)*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = read_32bitLE(loop_offsets,streamFile)*28/16/channel_count;
|
||||
}
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
vgmstream->meta_type = meta_MUSX_V201;
|
||||
|
||||
{
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 32000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = read_32bitLE(loop_offsets,streamFile)*28/16/channel_count;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(loop_offsets+0x10,streamFile)*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = read_32bitLE(loop_offsets,streamFile)*28/16/channel_count;
|
||||
}
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x80;
|
||||
vgmstream->meta_type = meta_MUSX_V201;
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
@ -517,9 +491,7 @@ VGMSTREAM * init_vgmstream_musx_v201(STREAMFILE *streamFile) {
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
/* <--------------------------------------- MUSX (Version 201) */
|
||||
|
Loading…
Reference in New Issue
Block a user