diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 58df0551..2d569530 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1,7 +1,7 @@  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) != 0x52414450) /* RADP */ + 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_RAD_IMA; + vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/0x14/channel_count*32; + 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_none; + vgmstream->interleave_block_size = 0x14*channel_count; + vgmstream->meta_type = meta_RSD4RADP; + + /* 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].offset=vgmstream->ch[i].channel_start_offset=start_offset; + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} + +/* RSD6RADP */ +VGMSTREAM * init_vgmstream_rsd6radp(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) != 0x52414450) /* RADP */ + 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_RAD_IMA; + vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/0x14/channel_count*32; + 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_none; + vgmstream->interleave_block_size = 0x14*channel_count; + vgmstream->meta_type = meta_RSD6RADP; + + /* 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].offset=vgmstream->ch[i].channel_start_offset=start_offset; + } + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} /* RSD6VAG */ VGMSTREAM * init_vgmstream_rsd6vag(STREAMFILE *streamFile) { @@ -909,68 +1029,6 @@ fail: return NULL; } -/* RSD6RADP */ -VGMSTREAM * init_vgmstream_rsd6radp(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) != 0x52414450) /* RADP */ - 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_RAD_IMA; - vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/0x14/channel_count*32; - 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_none; - vgmstream->interleave_block_size = 0x14*channel_count; - vgmstream->meta_type = meta_RSD6RADP; - - /* 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].offset=vgmstream->ch[i].channel_start_offset=start_offset; - } - } - - return vgmstream; - -fail: - /* clean up anything we may have opened */ - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} - - #if 0 /* RSD6XMA */ VGMSTREAM * init_vgmstream_rsd6xma(STREAMFILE *streamFile) { diff --git a/src/vgmstream.c b/src/vgmstream.c index aecb2f8a..3de4f11f 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -161,6 +161,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_rsd3pcmb, init_vgmstream_rsd4pcmb, init_vgmstream_rsd4pcm, + init_vgmstream_rsd4radp, init_vgmstream_rsd4vag, init_vgmstream_rsd6vag, init_vgmstream_rsd6wadp, @@ -2122,6 +2123,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_RSD4PCM: snprintf(temp,TEMPSIZE,"RSD4/PCM Header"); + break; + case meta_RSD4RADP: + snprintf(temp,TEMPSIZE,"RSD4/RADP Header"); break; case meta_RSD4VAG: snprintf(temp,TEMPSIZE,"RSD4/VAG Header"); diff --git a/src/vgmstream.h b/src/vgmstream.h index e84c0ae0..92843b15 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -312,6 +312,7 @@ typedef enum { meta_RSD3PCMB, /* RSD3PCMB */ meta_RSD4PCMB, /* RSD4PCMB */ meta_RSD4PCM, /* RSD4PCM */ + meta_RSD4RADP, /* RSD4RADP */ meta_RSD4VAG, /* RSD4VAG */ meta_RSD6VAG, /* RSD6VAG */ meta_RSD6WADP, /* RSD6WADP */