From cd7367c50058a2aa7bc4b7f20f5ab7ab2ef2e516 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Sun, 2 Nov 2008 16:43:12 +0000 Subject: [PATCH] naomi_spsd.c added (Naomi GD-ROM / Dreamcast) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@458 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 + src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 8 + src/meta/naomi_spsd.c | 73 ++++ src/meta/rsd.c | 897 +++++++++++++++++++++++--------------- src/vgmstream.c | 13 + src/vgmstream.h | 5 + winamp/in_vgmstream.c | 1 + 9 files changed, 664 insertions(+), 341 deletions(-) create mode 100644 src/meta/naomi_spsd.c diff --git a/src/Makefile b/src/Makefile index c45d8a22..e7314614 100644 --- a/src/Makefile +++ b/src/Makefile @@ -141,7 +141,8 @@ META_OBJS=meta/adx_header.o \ meta/ps2_mihb.o \ meta/ngc_pdt.o \ meta/wii_mus.o \ - meta/dc_asd.o + meta/dc_asd.o \ + meta/naomi_spsd.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 92bc1d43..ab5f6a5b 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -321,6 +321,10 @@ RelativePath=".\meta\musx.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 9c44eb93..84ab4f65 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -110,4 +110,5 @@ libmeta_la_SOURCES += ps2_mihb.c libmeta_la_SOURCES += ngc_pdt.c libmeta_la_SOURCES += wii_mus.c libmeta_la_SOURCES += dc_asd.c +libmeta_la_SOURCES += naomi_spsd.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index 46131e0a..cdc4731c 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -243,10 +243,18 @@ VGMSTREAM * init_vgmstream_rsd2xadp(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_rsd4pcmb(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_rsd4pcm(STREAMFILE * streamFile); + VGMSTREAM * init_vgmstream_rsd4vag(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_rsd6wadp(STREAMFILE * streamFile); + +VGMSTREAM * init_vgmstream_rsd6xadp(STREAMFILE * streamFile); + VGMSTREAM * init_vgmstream_dc_asd(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE * streamFile); + #endif diff --git a/src/meta/naomi_spsd.c b/src/meta/naomi_spsd.c new file mode 100644 index 00000000..349ec5ad --- /dev/null +++ b/src/meta/naomi_spsd.c @@ -0,0 +1,73 @@ +#include "meta.h" +#include "../util.h" + +/* SPSD (Guilty Gear X [NAOMI GD-ROM]) */ +VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("spsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x53505344) /* "SPSD" */ + goto fail; + + loop_flag = 0; + channel_count = 2; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->channels = channel_count; + start_offset = 0x40; + vgmstream->sample_rate = read_32bitLE(0x2A,streamFile); + vgmstream->coding_type = coding_AICA; + + vgmstream->num_samples = read_32bitLE(0x0C,streamFile); + + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile); + } + + vgmstream->interleave_block_size = 0x2000; + if (channel_count > 1) { + vgmstream->interleave_smallblock_size = ((get_streamfile_size(streamFile)-start_offset)%(vgmstream->channels*vgmstream->interleave_block_size))/vgmstream->channels; + vgmstream->layout_type = layout_interleave_shortblock; + } else { + vgmstream->layout_type = layout_none; + } + + vgmstream->meta_type = meta_NAOMI_SPSD; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/rsd.c b/src/meta/rsd.c index 3e21d93b..b0e45352 100644 --- a/src/meta/rsd.c +++ b/src/meta/rsd.c @@ -1,341 +1,558 @@ -#include "meta.h" -#include "../util.h" - -/* RSD */ -/* RSD2VAG */ -VGMSTREAM * init_vgmstream_rsd2vag(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("rsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */ - goto fail; - if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ - goto fail; - - loop_flag = 0; - channel_count = read_32bitLE(0x8,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(0x10,streamFile); - vgmstream->coding_type = coding_PSX; - vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - if (loop_flag) { - vgmstream->loop_start_sample = loop_flag; - vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - } - - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile); - vgmstream->meta_type = meta_RSD2VAG; - - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} - - -/* RSD2XADP */ -VGMSTREAM * init_vgmstream_rsd2xadp(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("rsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */ - goto fail; - if (read_32bitBE(0x4,streamFile) != 0x58414450) /* XADP */ - goto fail; - - loop_flag = 0; - channel_count = read_32bitLE(0x8,streamFile); - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - /* fill in the vital statistics */ - start_offset = read_32bitLE(0x18,streamFile); /* not sure about this */ - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitLE(0x10,streamFile); - vgmstream->coding_type = coding_XBOX; - vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)*64/36/channel_count; - if (loop_flag) { - vgmstream->loop_start_sample = loop_flag; - vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-start_offset)*28/16/channel_count; - } - - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x24; - vgmstream->meta_type = meta_RSD2XADP; - - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - - - if (vgmstream->coding_type == coding_XBOX) { - vgmstream->layout_type=layout_none; - vgmstream->ch[i].channel_start_offset=start_offset; - } else { - vgmstream->ch[i].channel_start_offset= - start_offset+vgmstream->interleave_block_size*i; - } - vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset; - - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} - - - -/* RSD4VAG */ -VGMSTREAM * init_vgmstream_rsd4vag(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("rsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */ - goto fail; - if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ - goto fail; - - loop_flag = 0; - channel_count = read_32bitLE(0x8,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(0x10,streamFile); - vgmstream->coding_type = coding_PSX; - vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - if (loop_flag) { - vgmstream->loop_start_sample = loop_flag; - vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - } - - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile); - vgmstream->meta_type = meta_RSD4VAG; - - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} - - - -/* RSD4PCMB */ -VGMSTREAM * init_vgmstream_rsd4pcmb(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("rsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */ - goto fail; - if (read_32bitBE(0x4,streamFile) != 0x50434D42) /* PCMB */ - goto fail; - - loop_flag = 0; - channel_count = read_32bitLE(0x8,streamFile); - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - /* fill in the vital statistics */ - start_offset = 0x80; - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitLE(0x10,streamFile); - vgmstream->coding_type = coding_PCM16BE; - vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/channel_count; - if (loop_flag) { - vgmstream->loop_start_sample = loop_flag; - vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)/2/channel_count; - } - - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x2; - vgmstream->meta_type = meta_RSD4PCMB; - - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} - - - -/* RSD6VAG */ -VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("rsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x0,streamFile) != 0x52534436) /* RSD6 */ - goto fail; - if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ - goto fail; - - loop_flag = 0; - channel_count = read_32bitLE(0x8,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(0x10,streamFile); - vgmstream->coding_type = coding_PSX; - vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - if (loop_flag) { - vgmstream->loop_start_sample = loop_flag; - vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; - } - - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile); - vgmstream->meta_type = meta_RSD6VAG; - - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; +#include "meta.h" +#include "../util.h" + +/* RSD */ +/* RSD2VAG */ +VGMSTREAM * init_vgmstream_rsd2vag(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile); + vgmstream->meta_type = meta_RSD2VAG; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + +/* RSD2XADP */ +VGMSTREAM * init_vgmstream_rsd2xadp(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534432) /* RSD2 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x58414450) /* XADP */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = read_32bitLE(0x18,streamFile); /* not sure about this */ + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x10,streamFile); + vgmstream->coding_type = coding_XBOX; + vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)*64/36/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-start_offset)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x24; + vgmstream->meta_type = meta_RSD2XADP; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + + if (vgmstream->coding_type == coding_XBOX) { + vgmstream->layout_type=layout_none; + vgmstream->ch[i].channel_start_offset=start_offset; + } else { + vgmstream->ch[i].channel_start_offset= + start_offset+vgmstream->interleave_block_size*i; + } + vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + + +/* RSD4VAG */ +VGMSTREAM * init_vgmstream_rsd4vag(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile); + vgmstream->meta_type = meta_RSD4VAG; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + +/* RSD4PCM - Little Endian */ +VGMSTREAM * init_vgmstream_rsd4pcm(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x50434D20) /* PCM\0x20 */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_PCM16LE; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)/2/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2; + vgmstream->meta_type = meta_RSD4PCM; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + + +/* RSD4PCMB - Big Endian */ +VGMSTREAM * init_vgmstream_rsd4pcmb(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534434) /* RSD4 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x50434D42) /* PCMB */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x80; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x10,streamFile); + vgmstream->coding_type = coding_PCM16BE; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/2/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)/2/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2; + vgmstream->meta_type = meta_RSD4PCMB; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + + +/* RSD6VAG */ +VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534436) /* RSD6 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x56414720) /* VAG\0x20 */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile); + vgmstream->meta_type = meta_RSD6VAG; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + +/* RSD6WADP */ +VGMSTREAM * init_vgmstream_rsd6wadp(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534436) /* RSD6 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x57414450) /* WADP */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-0x800)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0xC,streamFile); + vgmstream->meta_type = meta_RSD6WADP; + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x1A2+i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x1CA+i*2,streamFile); + } + } + } + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + + + +/* RSD6XADP */ +VGMSTREAM * init_vgmstream_rsd6xadp(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("rsd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x52534436) /* RSD6 */ + goto fail; + if (read_32bitBE(0x4,streamFile) != 0x58414450) /* XADP */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x8,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(0x10,streamFile); + vgmstream->coding_type = coding_XBOX; + vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)*64/36/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile)-start_offset)*28/16/channel_count; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x24; + vgmstream->meta_type = meta_RSD6XADP; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + + if (vgmstream->coding_type == coding_XBOX) { + vgmstream->layout_type=layout_none; + vgmstream->ch[i].channel_start_offset=start_offset; + } else { + vgmstream->ch[i].channel_start_offset= + start_offset+vgmstream->interleave_block_size*i; + } + vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset; + + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; } \ No newline at end of file diff --git a/src/vgmstream.c b/src/vgmstream.c index 256c862d..beae0923 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -135,12 +135,16 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ngc_pdt, init_vgmstream_wii_mus, init_vgmstream_dc_asd, + init_vgmstream_naomi_spsd, init_vgmstream_rsd2vag, init_vgmstream_rsd2xadp, init_vgmstream_rsd4pcmb, + init_vgmstream_rsd4pcm, init_vgmstream_rsd4vag, init_vgmstream_rsd6vag, + init_vgmstream_rsd6wadp, + init_vgmstream_rsd6xadp, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1727,15 +1731,24 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_RSD4PCMB: snprintf(temp,TEMPSIZE,"RSD4/PCMB Header"); + break; + case meta_RSD4PCM: + snprintf(temp,TEMPSIZE,"RSD4/PCM Header"); break; case meta_RSD4VAG: snprintf(temp,TEMPSIZE,"RSD4/VAG Header"); + break; + case meta_RSD6XADP: + snprintf(temp,TEMPSIZE,"RSD6/XADP Header"); break; case meta_RSD6VAG: snprintf(temp,TEMPSIZE,"RSD6/VAG Header"); break; case meta_DC_ASD: snprintf(temp,TEMPSIZE,"ASD Header"); + break; + case meta_NAOMI_SPSD: + snprintf(temp,TEMPSIZE,"SPSD Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 89678d50..59dbdf49 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -242,11 +242,16 @@ typedef enum { meta_PS2_MIHB, /* Merged MIH+MIB */ meta_NGC_PDT, /* Mario Party 6 */ meta_DC_ASD, /* Miss Moonligh */ + meta_NAOMI_SPSD, /* Guilty Gear X */ + meta_RSD2VAG, /* RSD2VAG */ meta_RSD2XADP, /* RSD2XADP */ meta_RSD4PCMB, /* RSD4PCMB */ + meta_RSD4PCM, /* RSD4PCM */ meta_RSD4VAG, /* RSD4VAG */ meta_RSD6VAG, /* RSD6VAG */ + meta_RSD6WADP, /* RSD6WADP */ + meta_RSD6XADP, /* RSD6XADP */ meta_XBOX_WAVM, /* XBOX WAVM File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 33722b4c..436b1a0d 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -191,6 +191,7 @@ char * extension_list[] = { "mihb\0MIHB Audio File (*.MIHB)\0", "pdt\0PDT Audio File (*.PDT)\0", "asd\0ASD Audio File (*.ASD)\0", + "spsd\0SPSD Audio File (*.SPSD)\0", }; void about(HWND hwndParent) {