2008-05-15 20:57:03 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
/* MIC
|
|
|
|
|
|
|
|
PS2 MIC format is an interleaved format found in most of KOEI Games
|
|
|
|
The header always start the long value 0x800 which is the start
|
|
|
|
of the BGM datas.
|
|
|
|
|
|
|
|
2008-05-15 - Fastelbja : First version ...
|
|
|
|
*/
|
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ps2_mic(STREAMFILE *streamFile) {
|
2008-05-15 20:57:03 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2013-05-27 05:55:50 +02:00
|
|
|
char filename[PATH_LIMIT];
|
2008-05-15 20:57:03 +02:00
|
|
|
|
|
|
|
int loop_flag=0;
|
|
|
|
int channel_count;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2008-05-20 17:18:38 +02:00
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
2008-05-15 20:57:03 +02:00
|
|
|
if (strcasecmp("mic",filename_extension(filename))) goto fail;
|
|
|
|
|
2008-05-17 17:39:02 +02:00
|
|
|
/* check Header */
|
2008-05-20 17:18:38 +02:00
|
|
|
if (read_32bitLE(0x00,streamFile) != 0x800)
|
2008-05-15 20:57:03 +02:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* check loop */
|
2008-05-20 17:18:38 +02:00
|
|
|
loop_flag = (read_32bitLE(0x14,streamFile)!=1);
|
2008-05-15 20:57:03 +02:00
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
channel_count=read_32bitLE(0x08,streamFile);
|
2008-05-15 20:57:03 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
vgmstream->channels = channel_count;
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
|
2008-05-15 20:57:03 +02:00
|
|
|
|
|
|
|
/* Compression Scheme */
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->num_samples = read_32bitLE(0x10,streamFile)*14*channel_count;
|
2008-05-15 20:57:03 +02:00
|
|
|
|
|
|
|
/* Get loop point values */
|
|
|
|
if(vgmstream->loop_flag) {
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile)*14*channel_count;
|
|
|
|
vgmstream->loop_end_sample = read_32bitLE(0x10,streamFile)*14*channel_count;
|
2008-05-15 20:57:03 +02:00
|
|
|
}
|
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0x0C,streamFile);
|
2008-05-15 20:57:03 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->meta_type = meta_PS2_MIC;
|
|
|
|
|
|
|
|
/* 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-05-15 20:57:03 +02:00
|
|
|
|
|
|
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=
|
|
|
|
(off_t)(0x800+vgmstream->interleave_block_size*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|