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
|
|
|
|
2017-11-19 03:34:25 +01:00
|
|
|
/* .MYSPF - from U-Sing (Wii) */
|
2010-01-10 22:22:20 +01:00
|
|
|
VGMSTREAM * init_vgmstream_myspd(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2017-11-19 03:34:25 +01:00
|
|
|
int loop_flag = 0, channel_count;
|
2010-01-10 22:22:20 +01:00
|
|
|
off_t start_offset;
|
2017-11-19 03:34:25 +01:00
|
|
|
size_t channel_size;
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2017-11-19 03:34:25 +01:00
|
|
|
if (!check_extensions(streamFile,"myspd"))
|
|
|
|
goto fail;
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
channel_count = 2;
|
|
|
|
start_offset = 0x20;
|
2017-11-19 03:34:25 +01:00
|
|
|
channel_size = read_32bitBE(0x00,streamFile);
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
/* check size */
|
2017-11-19 03:34:25 +01:00
|
|
|
if ((channel_size * channel_count + start_offset) != get_streamfile_size(streamFile))
|
2010-01-10 22:22:20 +01:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-11-19 03:34:25 +01:00
|
|
|
vgmstream->num_samples = ima_bytes_to_samples(channel_size*channel_count, channel_count);
|
|
|
|
vgmstream->sample_rate = read_32bitBE(0x04,streamFile);
|
2010-01-10 22:22:20 +01:00
|
|
|
|
|
|
|
vgmstream->meta_type = meta_MYSPD;
|
2017-11-19 03:34:25 +01:00
|
|
|
vgmstream->coding_type = coding_IMA_int;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = channel_size;
|
|
|
|
|
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
|
|
|
|
2010-01-10 22:22:20 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|