vgmstream/src/meta/nub_idsp.c

56 lines
1.9 KiB
C
Raw Normal View History

#include "meta.h"
2018-08-28 20:35:07 +02:00
#include "../coding/coding.h"
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) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
2018-08-28 20:35:07 +02:00
int loop_flag, channel_count;
2018-08-28 20:35:07 +02:00
/* checks */
if ( !check_extensions(streamFile,"idsp") )
goto fail;
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" */
goto fail;
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);
/* build the VGMSTREAM */
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;
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);
if (loop_flag) {
vgmstream->loop_start_sample = (read_32bitBE(0xD0,streamFile));
vgmstream->loop_end_sample = (read_32bitBE(0xD4,streamFile));
}
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;
2018-08-28 20:35:07 +02:00
dsp_read_coefs_be(vgmstream,streamFile,0x118,0x60);
2018-08-28 20:35:07 +02:00
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
2018-08-28 20:35:07 +02:00
close_vgmstream(vgmstream);
return NULL;
}