mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 09:40:51 +01:00
added dsp format to .emff.c
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@517 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
1707941016
commit
6f2ee1c123
@ -85,8 +85,11 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM *
|
||||
case layout_de2_blocked:
|
||||
de2_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
break;
|
||||
case layout_emff_blocked:
|
||||
emff_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
case layout_emff_ps2_blocked:
|
||||
emff_ps2_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
break;
|
||||
case layout_emff_ngc_blocked:
|
||||
emff_ngc_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
break;
|
||||
case layout_vs_blocked:
|
||||
vs_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "../vgmstream.h"
|
||||
|
||||
/* set up for the block at the given offset */
|
||||
void emff_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
void emff_ps2_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
int i;
|
||||
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
@ -16,3 +16,19 @@ void emff_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
vgmstream->ch[i].offset = vgmstream->current_block_offset+0x20+(vgmstream->current_block_size*i);
|
||||
}
|
||||
}
|
||||
|
||||
void emff_ngc_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
int i;
|
||||
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->current_block_size = read_32bitBE(
|
||||
vgmstream->current_block_offset+0x20,
|
||||
vgmstream->ch[0].streamfile);
|
||||
vgmstream->next_block_offset = vgmstream->current_block_offset + vgmstream->current_block_size+0x40;
|
||||
vgmstream->current_block_size/=vgmstream->channels;
|
||||
|
||||
for (i=0;i<vgmstream->channels;i++) {
|
||||
vgmstream->ch[i].offset = vgmstream->current_block_offset+0x40+(vgmstream->current_block_size*i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,9 @@ void de2_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
void vs_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
void emff_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
void emff_ps2_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
void emff_ngc_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
void xvas_block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
#include "layout.h"
|
||||
#include "../vgmstream.h"
|
||||
|
||||
/* set up for the block at the given offset */
|
||||
void test_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
int i;
|
||||
|
||||
vgmstream->current_block_offset = block_offset;
|
||||
vgmstream->current_block_size = read_32bitLE(
|
||||
vgmstream->current_block_offset+0x10,
|
||||
vgmstream->ch[0].streamfile);
|
||||
vgmstream->next_block_offset = vgmstream->current_block_offset + vgmstream->current_block_size+0x20;
|
||||
vgmstream->current_block_size/=vgmstream->channels;
|
||||
|
||||
for (i=0;i<vgmstream->channels;i++) {
|
||||
vgmstream->ch[i].offset = vgmstream->current_block_offset+0x20+(vgmstream->current_block_size*i);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
VGMSTREAM * init_vgmstream_test(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
off_t start_offset;
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int i;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("test",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
#if 0
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = read_32bitLE(0x0c,streamFile);;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x800;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x00,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
/* vgmstream->num_samples = read_32bitLE(0x08,streamFile); */
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x08,streamFile);
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_test_blocked;
|
||||
vgmstream->interleave_block_size = 0x10;
|
||||
vgmstream->meta_type = meta_TEST;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x2000);
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Calc num_samples */
|
||||
test_block_update(start_offset,vgmstream);
|
||||
vgmstream->num_samples=0;
|
||||
|
||||
do {
|
||||
vgmstream->num_samples += vgmstream->current_block_size*28/16;
|
||||
test_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
} while (vgmstream->next_block_offset<get_streamfile_size(streamFile));
|
||||
|
||||
test_block_update(start_offset,vgmstream);
|
||||
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
168
src/meta/emff.c
168
src/meta/emff.c
@ -3,70 +3,190 @@
|
||||
#include "../util.h"
|
||||
|
||||
/*
|
||||
|
||||
...EMFF - Eidos Music File Format...
|
||||
|
||||
EMFF - Eidos Music File Format (PS2),
|
||||
found in Tomb Raider Legend/Anniversary, Legacy of Kain - Defiance, possibly more...
|
||||
*/
|
||||
|
||||
VGMSTREAM * init_vgmstream_emff(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * init_vgmstream_emff_ps2(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
off_t start_offset;
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int frequency;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("emff",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
#if 0
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */
|
||||
goto fail;
|
||||
#endif
|
||||
/* do some checks on the file, cause we have no magic words to check the header...
|
||||
it seems if 0x800 and 0x804 = 0 then the file has only audio, if 0x800 = 1
|
||||
it has a text section, if both are 1 it's video with a text section included... */
|
||||
|
||||
if (read_32bitBE(0x800,streamFile) == 0x01000000 || /* "0x01000000" */
|
||||
read_32bitBE(0x804,streamFile) == 0x01000000) /* "0x01000000" */
|
||||
goto fail;
|
||||
|
||||
|
||||
frequency = read_32bitLE(0x0,streamFile);
|
||||
channel_count = read_32bitLE(0xC,streamFile);
|
||||
|
||||
|
||||
if (frequency > 48000 ||
|
||||
channel_count > 8) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = (read_32bitLE(0x4,streamFile) != 0xFFFFFFFF);
|
||||
|
||||
loop_flag = (read_32bitLE(0x04,streamFile) != 0xFFFFFFFF);
|
||||
channel_count = read_32bitLE(0x0C,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
|
||||
start_offset = 0x800;
|
||||
vgmstream->sample_rate = frequency;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x00,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
/* vgmstream->num_samples = read_32bitLE(0x08,streamFile); */
|
||||
|
||||
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = loop_flag;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x08,streamFile);
|
||||
vgmstream->loop_start_sample = (read_32bitLE(0x28,streamFile)-start_offset)*28/16/channel_count;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x8,streamFile);
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_emff_blocked;
|
||||
vgmstream->layout_type = layout_emff_ps2_blocked;
|
||||
vgmstream->interleave_block_size = 0x10;
|
||||
vgmstream->meta_type = meta_EMFF;
|
||||
vgmstream->meta_type = meta_EMFF_PS2;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
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 = streamFile->open(streamFile,filename,0x2000);
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Calc num_samples */
|
||||
emff_block_update(start_offset,vgmstream);
|
||||
emff_ps2_block_update(start_offset,vgmstream);
|
||||
vgmstream->num_samples=0;
|
||||
|
||||
do {
|
||||
vgmstream->num_samples += vgmstream->current_block_size*28/16/channel_count;
|
||||
emff_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
|
||||
vgmstream->num_samples += vgmstream->current_block_size*28/16;
|
||||
emff_ps2_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
} while (vgmstream->next_block_offset<get_streamfile_size(streamFile));
|
||||
|
||||
emff_block_update(start_offset,vgmstream);
|
||||
emff_ps2_block_update(start_offset,vgmstream);
|
||||
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
EMFF - Eidos Music File Format (NGC/WII),
|
||||
found in Tomb Raider Legend/Anniversary, Legacy of Kain - Defiance, possibly more...
|
||||
*/
|
||||
|
||||
VGMSTREAM * init_vgmstream_emff_ngc(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
off_t start_offset;
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int frequency;
|
||||
int i;
|
||||
int j;
|
||||
off_t coef_table[8] = {0xC8,0xF6,0x124,0x152,0x180,0x1AE,0x1DC,0x20A};
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("emff",filename_extension(filename))) goto fail;
|
||||
|
||||
/* do some checks on the file, cause we have no magic words to check the header...
|
||||
it seems if 0x800 and 0x804 = 0 then the file has only audio, if 0x800 = 1
|
||||
it has a text section, if both are 1 it's video with a text section included... */
|
||||
|
||||
if (read_32bitBE(0x800,streamFile) == 0x00000001 || /* "0x00000001" */
|
||||
read_32bitBE(0x804,streamFile) == 0x00000001) /* "0x00000001" */
|
||||
goto fail;
|
||||
|
||||
|
||||
frequency = read_32bitBE(0x0,streamFile);
|
||||
channel_count = read_32bitBE(0xC,streamFile);
|
||||
|
||||
|
||||
if (frequency > 48000 ||
|
||||
channel_count > 8) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = (read_32bitBE(0x4,streamFile) != 0xFFFFFFFF);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
|
||||
start_offset = 0x800;
|
||||
vgmstream->sample_rate = frequency;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
|
||||
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0x28,streamFile)-start_offset)*14/8/channel_count;
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x8,streamFile);
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_emff_ngc_blocked;
|
||||
vgmstream->interleave_block_size = 0x10;
|
||||
vgmstream->meta_type = meta_EMFF_NGC;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
for (j=0;j<vgmstream->channels;j++) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_table[j]+i*2,streamFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Calc num_samples */
|
||||
emff_ngc_block_update(start_offset,vgmstream);
|
||||
vgmstream->num_samples=0;
|
||||
|
||||
do {
|
||||
|
||||
vgmstream->num_samples += vgmstream->current_block_size*14/8;
|
||||
emff_ngc_block_update(vgmstream->next_block_offset,vgmstream);
|
||||
} while (vgmstream->next_block_offset<get_streamfile_size(streamFile));
|
||||
|
||||
emff_ngc_block_update(start_offset,vgmstream);
|
||||
|
||||
|
||||
return vgmstream;
|
||||
|
@ -314,7 +314,9 @@ VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_wii_smp(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_emff(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_emff_ps2(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_emff_ngc(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_thp(STREAMFILE *streamFile);
|
||||
|
||||
|
@ -173,7 +173,8 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_vgs,
|
||||
init_vgmstream_dc_wav_dcs,
|
||||
init_vgmstream_wii_smp,
|
||||
init_vgmstream_emff,
|
||||
init_vgmstream_emff_ps2,
|
||||
init_vgmstream_emff_ngc,
|
||||
init_vgmstream_ss_stream,
|
||||
init_vgmstream_thp,
|
||||
init_vgmstream_wii_sts,
|
||||
@ -532,7 +533,8 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
||||
case layout_matx_blocked:
|
||||
case layout_de2_blocked:
|
||||
case layout_vs_blocked:
|
||||
case layout_emff_blocked:
|
||||
case layout_emff_ps2_blocked:
|
||||
case layout_emff_ngc_blocked:
|
||||
case layout_xvas_blocked:
|
||||
case layout_thp_blocked:
|
||||
render_vgmstream_blocked(buffer,sample_count,vgmstream);
|
||||
@ -1359,8 +1361,11 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case layout_vs_blocked:
|
||||
snprintf(temp,TEMPSIZE,"vs blocked");
|
||||
break;
|
||||
case layout_emff_blocked:
|
||||
snprintf(temp,TEMPSIZE,"EMFF blocked");
|
||||
case layout_emff_ps2_blocked:
|
||||
snprintf(temp,TEMPSIZE,"EMFF (PS2) blocked");
|
||||
break;
|
||||
case layout_emff_ngc_blocked:
|
||||
snprintf(temp,TEMPSIZE,"EMFF (NGC/WII) blocked");
|
||||
break;
|
||||
case layout_thp_blocked:
|
||||
snprintf(temp,TEMPSIZE,"THP Movie Audio blocked");
|
||||
@ -1905,7 +1910,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case meta_WII_SMP:
|
||||
snprintf(temp,TEMPSIZE,"SMP DSP Header");
|
||||
break;
|
||||
case meta_EMFF:
|
||||
case meta_EMFF_PS2:
|
||||
case meta_EMFF_NGC:
|
||||
snprintf(temp,TEMPSIZE,"Eidos Music File Format Header");
|
||||
break;
|
||||
case meta_THP:
|
||||
|
@ -120,7 +120,8 @@ typedef enum {
|
||||
layout_de2_blocked,
|
||||
layout_xvas_blocked,
|
||||
layout_vs_blocked,
|
||||
layout_emff_blocked,
|
||||
layout_emff_ps2_blocked,
|
||||
layout_emff_ngc_blocked,
|
||||
layout_thp_blocked,
|
||||
|
||||
#if 0
|
||||
@ -289,7 +290,8 @@ typedef enum {
|
||||
meta_VGS, /* Guitar Hero Encore - Rocks the 80s */
|
||||
meta_DC_WAV_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
|
||||
meta_WII_SMP, /* Mushroom Men - The Spore Wars */
|
||||
meta_EMFF, /* Eidos Music File Format */
|
||||
meta_EMFF_PS2, /* Eidos Music File Format for PS2*/
|
||||
meta_EMFF_NGC, /* Eidos Music File Format for NGC/WII */
|
||||
|
||||
meta_XBOX_WAVM, /* XBOX WAVM File */
|
||||
meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */
|
||||
|
Loading…
Reference in New Issue
Block a user