vgmstream/src/meta/omu.c

44 lines
1.1 KiB
C
Raw Normal View History

2021-11-18 00:17:17 +01:00
#include "meta.h"
/* IMU - found in Alter Echo (PS2) */
2023-06-25 16:22:29 +02:00
VGMSTREAM* init_vgmstream_omu(STREAMFILE* sf) {
2021-11-18 00:17:17 +01:00
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channels;
/* checks */
if (!is_id32be(0x00,sf, "OMU "))
2023-06-25 16:22:29 +02:00
return NULL;
2021-11-18 00:17:17 +01:00
if (!check_extensions(sf,"omu"))
2023-06-25 16:22:29 +02:00
return NULL;
2021-11-18 00:17:17 +01:00
if (!is_id32be(0x08,sf, "FRMT"))
2023-06-25 16:22:29 +02:00
return NULL;
2021-11-18 00:17:17 +01:00
loop_flag = 1;
channels = read_u8(0x14,sf);
start_offset = 0x40;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_s32le(0x10,sf);
vgmstream->num_samples = (read_u32le(0x3C,sf) / (vgmstream->channels*2));
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x200;
2023-06-25 16:22:29 +02:00
vgmstream->meta_type = meta_OMU;
2021-11-18 00:17:17 +01:00
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}