Merge pull request #299 from NicknineTheEagle/cue-loop

RIFF: Looping info from CUE chunk
This commit is contained in:
Christopher Snowhill 2018-09-21 17:38:02 -07:00 committed by GitHub
commit 25f82da164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,6 +244,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
long loop_start_ms = -1, loop_end_ms = -1; long loop_start_ms = -1, loop_end_ms = -1;
int32_t loop_start_wsmp = -1, loop_end_wsmp = -1; int32_t loop_start_wsmp = -1, loop_end_wsmp = -1;
int32_t loop_start_smpl = -1, loop_end_smpl = -1; int32_t loop_start_smpl = -1, loop_end_smpl = -1;
int32_t loop_start_cue = -1;
int FormatChunkFound = 0, DataChunkFound = 0, JunkFound = 0; int FormatChunkFound = 0, DataChunkFound = 0, JunkFound = 0;
@ -420,6 +421,18 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
mwv_ctrl_offset = current_chunk; mwv_ctrl_offset = current_chunk;
break; break;
case 0x63756520: /* "cue " (used in Source Engine for storing loop points) */
if (fmt.coding_type == coding_PCM16LE || fmt.coding_type == coding_MSADPCM) {
uint32_t num_cues = read_32bitLE(current_chunk + 0x08, streamFile);
if (num_cues == 1 || num_cues == 2) {
// The second cue sets loop end point but it's not actually used by the engine.
loop_flag = 1;
loop_start_cue = read_32bitLE(current_chunk + 0x20, streamFile);
}
}
break;
case 0x4A554E4B: /* "JUNK" */ case 0x4A554E4B: /* "JUNK" */
JunkFound = 1; JunkFound = 1;
break; break;
@ -643,6 +656,10 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
vgmstream->loop_start_sample = read_32bitLE(mwv_ctrl_offset+12, streamFile); vgmstream->loop_start_sample = read_32bitLE(mwv_ctrl_offset+12, streamFile);
vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_end_sample = vgmstream->num_samples;
} }
else if (loop_start_cue != -1) {
vgmstream->loop_start_sample = loop_start_cue;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
} }
if (mwv) { if (mwv) {
vgmstream->meta_type = meta_RIFF_WAVE_MWV; vgmstream->meta_type = meta_RIFF_WAVE_MWV;