From 07f9b7ea66879074a7e7b16b226de72e99a00e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francis=20Gagn=C3=A9?= Date: Wed, 9 Sep 2020 23:22:05 -0400 Subject: [PATCH] meta/ogg_vorbis: Support LOOPMS tags Teach the Ogg Vorbis parser to interpret the value from LOOPMS tags as a loop start position, measured in milliseconds (instead of the typical samples). Converting this value to samples requires the sample rate, so we must now read the sample rate before interpreting the tags. These tags are used in Sonic Robo Blast 2 (as of v2.2.6). --- src/meta/ogg_vorbis.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index 31af60a7..07c46558 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -431,6 +431,9 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb data = init_ogg_vorbis(streamFile, start, stream_size, &io); if (!data) goto fail; + ogg_vorbis_get_info(data, &channels, &sample_rate); + ogg_vorbis_get_samples(data, &num_samples); /* let libvorbisfile find total samples */ + /* search for loop comments */ {//todo ignore if loop flag already set? const char * comment = NULL; @@ -514,6 +517,12 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb loop_end_found = 1; } } + else if (strstr(comment,"LOOPMS=") == comment) { /* Sonic Robo Blast 2 */ + /* Convert from milliseconds to samples. */ + /* (x ms) * (y samples/s) / (1000 ms/s) */ + loop_start = atol(strrchr(comment,'=')+1) * sample_rate / 1000; + loop_flag = (loop_start >= 0); + } /* Hatsune Miku Project DIVA games, though only 'Arcade Future Tone' has >4ch files * ENCODER tag is common but ogg_vorbis_encode looks unique enough @@ -531,8 +540,6 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb } ogg_vorbis_set_disable_reordering(data, disable_reordering); - ogg_vorbis_get_info(data, &channels, &sample_rate); - ogg_vorbis_get_samples(data, &num_samples); /* let libvorbisfile find total samples */ /* build the VGMSTREAM */