2010-01-10 22:22:20 +01:00
|
|
|
#include "meta.h"
|
2017-11-19 03:34:25 +01:00
|
|
|
#include "../coding/coding.h"
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
|
2023-06-24 16:36:54 +02:00
|
|
|
/* .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;
|
2010-01-10 22:22:20 +01:00
|
|
|
start_offset = 0x20;
|
2023-06-24 16:36:54 +02:00
|
|
|
channel_size = read_s32be(0x00,sf);
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
/* check size */
|
2023-06-24 17:56:09 +02:00
|
|
|
if (channel_size * channels + start_offset != get_streamfile_size(sf))
|
|
|
|
goto fail;
|
2010-01-10 22:22:20 +01:00
|
|
|
|
2023-06-24 17:56:09 +02:00
|
|
|
/* build the VGMSTREAM */
|
2023-06-24 16:36:54 +02:00
|
|
|
vgmstream = allocate_vgmstream(channels,loop_flag);
|
2010-01-10 22:22:20 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2023-06-24 17:56:09 +02:00
|
|
|
vgmstream->num_samples = ima_bytes_to_samples(channel_size*channels, channels);
|
2023-06-24 16:36:54 +02:00
|
|
|
vgmstream->sample_rate = read_s32be(0x04,sf);
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
vgmstream->meta_type = meta_MYSPD;
|
2023-06-24 17:56:09 +02:00
|
|
|
vgmstream->coding_type = coding_IMA_int;
|
2017-11-19 03:34:25 +01:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = channel_size;
|
|
|
|
|
2023-06-24 16:36:54 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
|
2017-11-19 03:34:25 +01:00
|
|
|
goto fail;
|
|
|
|
|
2010-01-10 22:22:20 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|