2009-03-30 17:43:26 +02:00
|
|
|
#include "meta.h"
|
2018-08-28 20:35:07 +02:00
|
|
|
#include "../coding/coding.h"
|
2009-03-30 17:43:26 +02:00
|
|
|
|
2018-08-12 18:04:19 +02:00
|
|
|
|
|
|
|
/* "idsp" - from Namco's Wii NUB archives [Soul Calibur Legends (Wii), Sky Crawlers: Innocent Aces (Wii)] */
|
|
|
|
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE *streamFile) {
|
2009-03-30 17:43:26 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2010-04-20 22:26:10 +02:00
|
|
|
off_t start_offset;
|
2018-08-28 20:35:07 +02:00
|
|
|
int loop_flag, channel_count;
|
2009-03-30 17:43:26 +02:00
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
/* checks */
|
|
|
|
if ( !check_extensions(streamFile,"idsp") )
|
|
|
|
goto fail;
|
2009-03-30 17:43:26 +02:00
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
/* actual header starts at "IDSP", while "idsp" is mostly nub bank stuff */
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x69647370) /* "idsp" */
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0xBC,streamFile) != 0x49445350) /* "IDSP" */
|
2018-03-24 19:27:24 +01:00
|
|
|
goto fail;
|
2009-03-30 17:43:26 +02:00
|
|
|
|
|
|
|
loop_flag = read_32bitBE(0x20,streamFile);
|
|
|
|
channel_count = read_32bitBE(0xC4,streamFile);
|
2018-08-28 20:35:07 +02:00
|
|
|
if (channel_count > 8) goto fail;
|
|
|
|
|
|
|
|
start_offset = 0x100 + (channel_count * 0x60);
|
2018-03-24 19:27:24 +01:00
|
|
|
|
2010-04-20 22:26:10 +02:00
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
/* build the VGMSTREAM */
|
2009-03-30 17:43:26 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
vgmstream->meta_type = meta_NUB_IDSP;
|
2018-03-24 19:27:24 +01:00
|
|
|
vgmstream->sample_rate = read_32bitBE(0xC8,streamFile);
|
2018-08-28 20:35:07 +02:00
|
|
|
vgmstream->num_samples = dsp_bytes_to_samples(read_32bitBE(0x14,streamFile),channel_count);
|
2009-03-30 17:43:26 +02:00
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = (read_32bitBE(0xD0,streamFile));
|
|
|
|
vgmstream->loop_end_sample = (read_32bitBE(0xD4,streamFile));
|
|
|
|
}
|
2018-03-24 19:27:24 +01:00
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
vgmstream->coding_type = coding_NGC_DSP;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile);
|
|
|
|
if (vgmstream->interleave_block_size == 0)
|
|
|
|
vgmstream->interleave_block_size = (get_streamfile_size(streamFile) - start_offset) / channel_count;
|
2009-03-30 17:43:26 +02:00
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
dsp_read_coefs_be(vgmstream,streamFile,0x118,0x60);
|
2009-03-30 17:43:26 +02:00
|
|
|
|
2018-08-28 20:35:07 +02:00
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
2009-03-30 17:43:26 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-08-28 20:35:07 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2009-03-30 17:43:26 +02:00
|
|
|
return NULL;
|
|
|
|
}
|