mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-25 07:20:10 +01:00
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).
This commit is contained in:
parent
414aa219c8
commit
07f9b7ea66
@ -431,6 +431,9 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb
|
|||||||
data = init_ogg_vorbis(streamFile, start, stream_size, &io);
|
data = init_ogg_vorbis(streamFile, start, stream_size, &io);
|
||||||
if (!data) goto fail;
|
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 */
|
/* search for loop comments */
|
||||||
{//todo ignore if loop flag already set?
|
{//todo ignore if loop flag already set?
|
||||||
const char * comment = NULL;
|
const char * comment = NULL;
|
||||||
@ -514,6 +517,12 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb
|
|||||||
loop_end_found = 1;
|
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
|
/* Hatsune Miku Project DIVA games, though only 'Arcade Future Tone' has >4ch files
|
||||||
* ENCODER tag is common but ogg_vorbis_encode looks unique enough
|
* 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_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 */
|
/* build the VGMSTREAM */
|
||||||
|
Loading…
Reference in New Issue
Block a user