vgmstream/src/meta/myspd.c

45 lines
1.1 KiB
C
Raw Normal View History

#include "meta.h"
#include "../coding/coding.h"
/* .MYSPD - from U-Sing (Wii) */
VGMSTREAM* init_vgmstream_myspd(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int loop_flag = 0, channels;
uint32_t start_offset, channel_size;
/* checks */
/* .myspd: actual extension */
if (!check_extensions(sf,"myspd"))
return NULL;
channels = 2;
start_offset = 0x20;
channel_size = read_s32be(0x00,sf);
/* check size */
2023-06-24 17:56:09 +02:00
if (channel_size * channels + start_offset != get_streamfile_size(sf))
goto fail;
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->num_samples = ima_bytes_to_samples(channel_size*channels, channels);
vgmstream->sample_rate = read_s32be(0x04,sf);
vgmstream->meta_type = meta_MYSPD;
2023-06-24 17:56:09 +02:00
vgmstream->coding_type = coding_IMA_int;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = channel_size;
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
goto fail;
return vgmstream;
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}