Fix .ao loops [Cloudphobia (PC)]

This commit is contained in:
bnnm 2021-01-23 15:39:16 +01:00
parent d2f523f05d
commit 4635fe2011

View File

@ -1,36 +1,40 @@
#include "meta.h"
#include "../coding/coding.h"
/* .AO - from AlphaOgg lib [Cloudphobia (PC)] */
VGMSTREAM * init_vgmstream_ao(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
/* checks */
if ( !check_extensions(streamFile,"ao") )
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x414C5048) /* "ALPH" */
goto fail;
if (read_32bitBE(0x04,streamFile) != 0x414F4747) /* "AOGG" */
goto fail;
#ifdef VGM_USE_VORBIS
{
ogg_vorbis_meta_info_t ovmi = {0};
ovmi.meta_type = meta_AO;
/* values at 0x08/0x0c/0x10 may be related to looping? */
start_offset = 0xc8;
vgmstream = init_vgmstream_ogg_vorbis_callbacks(streamFile, NULL, start_offset, &ovmi);
}
#else
goto fail;
#endif
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
#include "meta.h"
#include "../coding/coding.h"
/* .AO - from AlphaOgg lib [Cloudphobia (PC), GEO ~The Sword Millennia~ Kasumi no Tani no Kaibutsu (PC)] */
VGMSTREAM* init_vgmstream_ao(STREAMFILE *sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
/* checks */
if (!check_extensions(sf,"ao"))
goto fail;
if (!is_id64be(0x00,sf, "ALPHAOGG"))
goto fail;
#ifdef VGM_USE_VORBIS
{
ogg_vorbis_meta_info_t ovmi = {0};
int sample_rate = read_u32le(0xF0, sf); /* Ogg header */
ovmi.meta_type = meta_AO;
ovmi.loop_start = read_f32le(0x08, sf) * sample_rate;
ovmi.loop_end = read_f32le(0x0c, sf) * sample_rate; /* also num_samples in some versions */
ovmi.loop_end_found = 1;
ovmi.loop_flag = read_u8(0x10, sf) != 0; /* count or -1=infinite, u32 in some versions */
/* AlphaOgg defines up to 16 loop points for some reason */
start_offset = 0xc8;
vgmstream = init_vgmstream_ogg_vorbis_callbacks(sf, NULL, start_offset, &ovmi);
}
#else
goto fail;
#endif
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}