Merge pull request #702 from FraGag/srb2

Parse loop points in Sonic Robo Blast 2's Ogg Vorbis music
This commit is contained in:
bnnm 2020-09-10 19:19:39 +02:00 committed by GitHub
commit a76abbcf17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
@ -439,6 +442,7 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb
if (strstr(comment,"loop_start=") == comment || /* PSO4 */
strstr(comment,"LOOP_START=") == comment || /* PSO4 */
strstr(comment,"LOOPPOINT=") == comment || /* Sonic Robo Blast 2 */
strstr(comment,"COMMENT=LOOPPOINT=") == comment ||
strstr(comment,"LOOPSTART=") == comment ||
strstr(comment,"um3.stream.looppoint.start=") == comment ||
@ -513,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
@ -530,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 */