Add Her Interactive Sound (.his)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@725 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2010-01-19 19:40:41 +00:00
parent 52190b4720
commit 2f60a76e8a
10 changed files with 106 additions and 1 deletions

View File

@ -150,6 +150,7 @@ PCM:
- .bh2pcm (16 bit)
- .gcsw (16 bit)
- .gcw (16 bit)
- .his (8 bit)
- .int (16 bit)
- .pcm (8 bit, 16 bit)
- .kraw (16 bit)

View File

@ -217,7 +217,8 @@ META_OBJS=meta/adx_header.o \
meta/xbox_hlwav.o \
meta/stx.o \
meta/ps2_stm.o \
meta/myspd.o
meta/myspd.o \
meta/his.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -328,6 +328,10 @@
RelativePath=".\meta\halpst.c"
>
</File>
<File
RelativePath=".\meta\his.c"
>
</File>
<File
RelativePath=".\meta\idsp.c"
>

View File

@ -175,5 +175,6 @@ libmeta_la_SOURCES += xbox_hlwav.c
libmeta_la_SOURCES += stx.c
libmeta_la_SOURCES += ps2_stm.c
libmeta_la_SOURCES += myspd.c
libmeta_la_SOURCES += his.c
EXTRA_DIST = meta.h

88
src/meta/his.c Normal file
View File

@ -0,0 +1,88 @@
#include "meta.h"
#include "../util.h"
/* Her Interactive Sound .his (Nancy Drew) */
VGMSTREAM * init_vgmstream_his(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int channel_count;
int loop_flag = 0;
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("his",filename_extension(filename))) goto fail;
/* check header magic */
const uint8_t header_magic_expected[0x16] = "Her Interactive Sound\x1a";
uint8_t header_magic[0x16];
if (0x16 != streamFile->read(streamFile, header_magic, 0, 0x16)) goto fail;
if (memcmp(header_magic_expected, header_magic, 0x16)) goto fail;
/* data chunk label */
if (0x64617461 != read_32bitBE(0x24,streamFile)) goto fail;
start_offset = 0x2c;
/* channel count is there twice, or one is bytes per frame */
channel_count = read_16bitLE(0x16,streamFile);
if (read_16bitLE(0x20,streamFile) != channel_count) goto fail;
/* 8-bit expected */
if (read_16bitLE(0x22,streamFile) != 8) goto fail;
/* check size */
/* file size -8, I assume taken from RIFF, though it doesn't describe this format well */
if ((read_32bitLE(0x1c,streamFile)+8) != get_streamfile_size(streamFile))
goto fail;
/* data chunk size, assume it occupies the rest of the file */
if ((read_32bitLE(0x28,streamFile)+start_offset) != get_streamfile_size(streamFile))
goto fail;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->num_samples = read_32bitLE(0x28,streamFile) / channel_count;
vgmstream->sample_rate = read_32bitLE(0x18,streamFile);
vgmstream->coding_type = coding_PCM8_U;
vgmstream->meta_type = meta_HIS;
vgmstream->layout_type = layout_none;
if (channel_count == 2)
{
vgmstream->coding_type = coding_PCM8_U_int;
vgmstream->interleave_block_size = 1;
}
/* open the file for reading */
{
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
vgmstream->ch[0].streamfile = file;
vgmstream->ch[0].channel_start_offset=
vgmstream->ch[0].offset=start_offset;
if (channel_count == 2)
{
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
vgmstream->ch[1].streamfile = file;
vgmstream->ch[0].channel_start_offset=
vgmstream->ch[1].offset=start_offset + vgmstream->interleave_block_size;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -431,4 +431,6 @@ VGMSTREAM * init_vgmstream_ps2_stm(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_myspd(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_his(STREAMFILE* streamFile);
#endif

View File

@ -236,6 +236,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_stx,
init_vgmstream_ps2_stm,
init_vgmstream_myspd,
init_vgmstream_his,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -2368,6 +2369,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_MYSPD:
snprintf(temp,TEMPSIZE,"U-Sing .myspd header");
break;
case meta_HIS:
snprintf(temp,TEMPSIZE,"Her Interactive Sound header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
}

View File

@ -211,6 +211,7 @@ typedef enum {
meta_GCSW, /* GCSW (PCM) */
meta_CFN, /* Namco CAF Audio File */
meta_MYSPD, /* U-Sing .myspd */
meta_HIS, /* Her Ineractive .his */
meta_PS2_SShd, /* .ADS with SShd header */
meta_PS2_NPSF, /* Namco Production Sound File */

View File

@ -77,6 +77,8 @@ gchar *vgmstream_exts [] = {
"gsb",
"hgc1",
"his",
"hlwav",
"hps",
"hwas",

View File

@ -141,6 +141,7 @@ char * extension_list[] = {
"gsb\0GSB Audio File (*.GSB)\0",
"hgc1\0HGC1 Audio File (*.HGC1)\0",
"his\0HIS Audio File (*.HIS)\0",
"hlwav\0HLWAV Audio File (*.HLWAV)\0",
"hps\0HALPST Audio File (*.HPS)\0",
"hwas\0HWAS Audio File (*.HWAS)\0",