2008-08-10 22:08:03 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
2008-08-11 09:19:44 +02:00
|
|
|
#include "../layout/layout.h"
|
2008-08-10 22:08:03 +02:00
|
|
|
|
|
|
|
/* matx
|
|
|
|
|
|
|
|
MATX (found in Matrix)
|
|
|
|
*/
|
|
|
|
|
|
|
|
VGMSTREAM * init_vgmstream_xbox_matx(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2013-05-27 05:55:50 +02:00
|
|
|
char filename[PATH_LIMIT];
|
2008-08-10 22:08:03 +02:00
|
|
|
|
|
|
|
int loop_flag=0;
|
|
|
|
int channel_count;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
|
|
if (strcasecmp("matx",filename_extension(filename))) goto fail;
|
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count=read_16bitLE(0x4,streamFile);
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = read_16bitLE(0x06,streamFile) & 0xffff;
|
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
vgmstream->coding_type = coding_XBOX_IMA;
|
2018-03-29 19:00:04 +02:00
|
|
|
vgmstream->layout_type = layout_blocked_matx;
|
2008-08-10 22:08:03 +02:00
|
|
|
vgmstream->meta_type = meta_XBOX_MATX;
|
|
|
|
|
|
|
|
/* open the file for reading by each channel */
|
|
|
|
{
|
|
|
|
for (i=0;i<channel_count;i++) {
|
2018-08-19 22:51:14 +02:00
|
|
|
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
2008-08-10 22:08:03 +02:00
|
|
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calc num_samples */
|
2018-03-29 19:00:04 +02:00
|
|
|
block_update_matx(0,vgmstream);
|
2008-08-10 22:08:03 +02:00
|
|
|
vgmstream->num_samples=0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
vgmstream->num_samples += vgmstream->current_block_size/36*64;
|
2018-03-29 19:00:04 +02:00
|
|
|
block_update_matx(vgmstream->next_block_offset,vgmstream);
|
2008-08-10 22:08:03 +02:00
|
|
|
} while (vgmstream->next_block_offset<get_streamfile_size(streamFile));
|
|
|
|
|
2018-03-29 19:00:04 +02:00
|
|
|
block_update_matx(0,vgmstream);
|
2008-08-10 22:08:03 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|