From 1eb20e259f8e8fb313287d043c939bb79dc6f38f Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Mon, 15 Mar 2010 04:33:22 +0000 Subject: [PATCH] ubisoft .sns (Red Steel 2) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@755 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- fb2k/in_vgmstream.cpp | 2 ++ readme.txt | 1 + src/meta/riff.c | 45 +++++++++++++++++++++++++++++++++++++++---- src/vgmstream.c | 3 +++ src/vgmstream.h | 1 + unix/data.c | 1 + winamp/in_vgmstream.c | 1 + 7 files changed, 50 insertions(+), 4 deletions(-) diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index ad74794e..c7e9c7c9 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -403,6 +403,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"smp")) return 1; if(!stricmp_utf8(p_extension,"snd")) return 1; if(!stricmp_utf8(p_extension,"sng")) return 1; + if(!stricmp_utf8(p_extension,"sns")) return 1; if(!stricmp_utf8(p_extension,"spd")) return 1; if(!stricmp_utf8(p_extension,"sps")) return 1; if(!stricmp_utf8(p_extension,"spsd")) return 1; @@ -659,6 +660,7 @@ DECLARE_MULTIPLE_FILE_TYPE("SLI Audio File (*.SLI)", sli); DECLARE_MULTIPLE_FILE_TYPE("SMP Audio File (*.SMP)", smp); DECLARE_MULTIPLE_FILE_TYPE("SND Audio File (*.SND)", snd); DECLARE_MULTIPLE_FILE_TYPE("SNG Audio File (*.SNG)", sng); +DECLARE_MULTIPLE_FILE_TYPE("SNS Audio File (*.SNS)", sns); DECLARE_MULTIPLE_FILE_TYPE("SPD Audio File (*.SPD)", spd); DECLARE_MULTIPLE_FILE_TYPE("SPS Audio File (*.SPS)", sps); DECLARE_MULTIPLE_FILE_TYPE("SPSD Audio File (*.SPSD)", spsd); diff --git a/readme.txt b/readme.txt index 2f597234..292f2cb7 100644 --- a/readme.txt +++ b/readme.txt @@ -127,6 +127,7 @@ GC/Wii DSP ADPCM: - .pdt - .sdt - .smp +- .sns - .spt+.spd - .ssm - .stm/.dsp diff --git a/src/meta/riff.c b/src/meta/riff.c index 18b5aa92..ecf1042c 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -111,15 +111,20 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { off_t mwv_pflt_offset = -1; off_t mwv_ctrl_offset = -1; + /* Ubisoft sns */ + int sns = 0; + /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); if (strcasecmp("wav",filename_extension(filename)) && strcasecmp("lwav",filename_extension(filename))) { - if (strcasecmp("mwv",filename_extension(filename))) - goto fail; - else + if (!strcasecmp("mwv",filename_extension(filename))) mwv = 1; + else if (!strcasecmp("sns",filename_extension(filename))) + sns = 1; + else + goto fail; } /* check header */ @@ -189,6 +194,11 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { coding_type = coding_L5_555; interleave = 0x12; break; + case 0x5050: /* Ubisoft .sns uses this for DSP */ + if (!sns) goto fail; + coding_type = coding_NGC_DSP; + interleave = 8; + break; default: goto fail; } @@ -244,7 +254,8 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { mwv_ctrl_offset = current_chunk; break; case 0x66616374: /* fact */ - if (chunk_size != 4) break; + if (chunk_size != 4 + && (!(sns && chunk_size == 0x10))) break; fact_sample_count = read_32bitLE(current_chunk+8, streamFile); break; default: @@ -274,6 +285,13 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { break; } + /* .sns uses fact chunk */ + if (sns) + { + if (-1 == fact_sample_count) goto fail; + sample_count = fact_sample_count; + } + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); @@ -346,6 +364,25 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { vgmstream->meta_type = meta_RIFF_WAVE_MWV; } + if (sns) + { + int c; + /* common codebook? */ + static const int16_t coef[16] = + {0x04ab,0xfced,0x0789,0xfedf,0x09a2,0xfae5,0x0c90,0xfac1, + 0x084d,0xfaa4,0x0982,0xfdf7,0x0af6,0xfafa,0x0be6,0xfbf5}; + + for (c = 0; c < channel_count; c++) + { + int i; + for (i = 0; i < 16; i++) + { + vgmstream->ch[c].adpcm_coef[i] = coef[i]; + } + } + vgmstream->meta_type = meta_RIFF_WAVE_SNS; + } + /* open the file, set up each channel */ { int i; diff --git a/src/vgmstream.c b/src/vgmstream.c index 8cc898e6..b812486b 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -2261,6 +2261,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_RIFF_WAVE_MWV: snprintf(temp,TEMPSIZE,"RIFF WAVE header with .mwv flavoring"); break; + case meta_RIFF_WAVE_SNS: + snprintf(temp,TEMPSIZE,"RIFF WAVE header with .sns flavoring"); + break; case meta_FFCC_STR: snprintf(temp,TEMPSIZE,"Final Fantasy: Crystal Chronicles STR header"); break; diff --git a/src/vgmstream.h b/src/vgmstream.h index 6870154b..bd2dba97 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -388,6 +388,7 @@ typedef enum { meta_RIFF_WAVE_labl_Marker, /* RIFF w/ loop Markers in LIST-adtl-labl */ meta_RIFF_WAVE_smpl, /* RIFF w/ loop data in smpl chunk */ meta_RIFF_WAVE_MWV, /* .mwv RIFF w/ loop data in ctrl chunk pflt */ + meta_RIFF_WAVE_SNS, /* .sns RIFF */ meta_RIFX_WAVE, /* RIFX, for big-endian WAVs */ meta_RIFX_WAVE_smpl, /* RIFX w/ loop data in smpl chunk */ meta_PC_MXST, /* Lego Island MxSt */ diff --git a/unix/data.c b/unix/data.c index a23a4424..d17f6573 100644 --- a/unix/data.c +++ b/unix/data.c @@ -163,6 +163,7 @@ gchar *vgmstream_exts [] = { "smp", "snd", "sng", + "sns", "spd", "sps", "spsd", diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index f9e386b1..4d03b4c1 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -231,6 +231,7 @@ char * extension_list[] = { "smp\0SMP Audio File (*.SMP)\0", "snd\0SND Audio File (*.SND)\0", "sng\0SNG Audio File (*.SNG)\0", + "sns\0SNS Audio File (*.SNS)\0", "spd\0SPD Audio File (*.SPD)\0", "sps\0SPS Audio File (*.SPS)\0", "spsd\0SPSD Audio File (*.SPSD)\0",