vgmstream/src/meta/ydsp.c

49 lines
1.4 KiB
C
Raw Normal View History

#include "meta.h"
2023-06-24 17:56:09 +02:00
#include "../coding/coding.h"
2023-06-24 17:56:09 +02:00
/* YDSP - from Yuke's games [WWE Day of Reckoning (GC), WWE WrestleMania XIX (GC)] */
VGMSTREAM* init_vgmstream_ydsp(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int channels, loop_flag;
uint32_t start_offset;
2023-06-24 17:56:09 +02:00
/* checks */
if (!is_id32be(0x00,sf, "YDSP"))
return NULL;
2023-06-24 17:56:09 +02:00
/* .ydsp: header id (in bigfile, .yds is the likely extension comparing similar files) */
if (!check_extensions(sf, "ydsp"))
return NULL;
2023-06-24 17:56:09 +02:00
loop_flag = (read_s32be(0xB0,sf) != 0x0);
channels = read_u16be(0x10,sf);
start_offset = 0x120;
2023-06-24 17:56:09 +02:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
2023-06-24 17:56:09 +02:00
vgmstream->meta_type = meta_YDSP;
vgmstream->sample_rate = read_s32be(0x0C,sf);
2023-06-24 17:56:09 +02:00
vgmstream->num_samples = dsp_bytes_to_samples(read_u32be(0x08,sf), channels);
vgmstream->loop_start_sample = read_s32be(0xB0,sf);
vgmstream->loop_end_sample = read_s32be(0xB4,sf);
2023-06-24 17:56:09 +02:00
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitBE(0x14,sf);
2023-06-24 17:56:09 +02:00
dsp_read_coefs_be(vgmstream, sf, 0x20, 0x24);
//dsp_read_hist_be(vgmstream, sf, 0x20 + 0x20, 0x24);
2023-06-24 17:56:09 +02:00
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
2023-06-24 17:56:09 +02:00
close_vgmstream(vgmstream);
return NULL;
}