nds swav added

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@575 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2009-02-06 19:16:37 +00:00
parent b1b0ca2f98
commit 019497f829
9 changed files with 113 additions and 10 deletions

View File

@ -178,7 +178,8 @@ META_OBJS=meta/adx_header.o \
meta/ps2_p2bt.o \
meta/ps2_gbts.o \
meta/ngc_ffcc_str.o \
meta/sat_baka.o
meta/sat_baka.o \
meta/nds_swav.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -370,6 +370,10 @@
RelativePath=".\meta\nds_strm.c"
>
</File>
<File
RelativePath=".\meta\nds_swav.c"
>
</File>
<File
RelativePath=".\meta\ngc_adpdtk.c"
>

View File

@ -139,5 +139,6 @@ libmeta_la_SOURCES += ps2_p2bt.c
libmeta_la_SOURCES += ps2_gbts.c
libmeta_la_SOURCES += ngc_ffcc_str.c
libmeta_la_SOURCES += sat_baka.c
libmeta_la_SOURCES += nds_swav.c
EXTRA_DIST = meta.h

View File

@ -63,15 +63,15 @@ VGMSTREAM * init_vgmstream_gsp_gsb(STREAMFILE *streamFile) {
vgmstream->meta_type = meta_GSP_GSB;
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=i*vgmstream->interleave_block_size;
}
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=i*vgmstream->interleave_block_size;
}
}
if (vgmstream->coding_type == coding_NGC_DSP) {

View File

@ -334,4 +334,6 @@ VGMSTREAM * init_vgmstream_ngc_ffcc_str(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sat_baka(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_nds_swav(STREAMFILE *streamFile);
#endif

89
src/meta/nds_swav.c Normal file
View File

@ -0,0 +1,89 @@
#include "meta.h"
#include "../util.h"
/* 28.01.2009 - bxaimc :
SWAV - found in Asphalt Urban GT & Asphalt Urban GT 2 */
VGMSTREAM * init_vgmstream_nds_swav(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int codec_number;
int channel_count;
int loop_flag;
coding_t coding_type;
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("swav",filename_extension(filename))) goto fail;
/* check header */
if ((uint32_t)read_32bitBE(0x00,streamFile)!=0x53574156) /* SWAV */
goto fail;
/* check for DATA section */
if ((uint32_t)read_32bitBE(0x10,streamFile)!=0x44415441) /* "DATA" */
goto fail;
/* check type details */
codec_number = read_8bit(0x18,streamFile);
loop_flag = read_32bitLE(0x20,streamFile);
channel_count = (uint16_t)read_16bitLE(0xE,streamFile);
switch (codec_number) {
case 0:
coding_type = coding_PCM8;
break;
case 1:
coding_type = coding_PCM16LE;
break;
case 2:
coding_type = coding_NDS_IMA;
break;
default:
goto fail;
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x24;
vgmstream->num_samples = (read_32bitLE(0x20,streamFile)*8)/channel_count;
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x1A,streamFile);
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x20,streamFile)*8)/channel_count;
}
vgmstream->coding_type = coding_type;
vgmstream->meta_type = meta_NDS_SWAV;
vgmstream->layout_type = layout_none;
/* open the file for reading by each channel */
{
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;
vgmstream->ch[i].adpcm_step_index = read_8bit(0x1F,streamFile);
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -187,6 +187,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_aax,
init_vgmstream_ngc_ffcc_str,
init_vgmstream_sat_baka,
init_vgmstream_nds_swav,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -2052,6 +2053,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_SAT_BAKA:
snprintf(temp,TEMPSIZE,"BAKA header from Crypt Killer");
break;
case meta_NDS_SWAV:
snprintf(temp,TEMPSIZE,"SWAV Header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
}

View File

@ -178,6 +178,7 @@ typedef enum {
meta_RSTM_SPM, /* RSTM with 44->22khz hack */
meta_THP,
meta_RSTM_shrunken, /* Atlus' mutant shortened RSTM */
meta_NDS_SWAV, /* Asphalt Urban GT 1 & 2 */
/* CRI ADX */
meta_ADX_03, /* ADX "type 03" */

View File

@ -224,6 +224,7 @@ char * extension_list[] = {
"mwv\0MWV Audio File (*.MWV)\0",
"rwav\0RWAV Audio File (*.RWAV)\0",
"baka\0BAKA Audio File (*.BAKA)\0",
"swav\0SWAV Audio File (*.SWAV)\0",
};
void about(HWND hwndParent) {