From a55b1061063f1d78530e50d847499320969628bb Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 1 Nov 2023 13:29:38 +0000 Subject: [PATCH] Better looping --- tracker/agb-midi-core/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tracker/agb-midi-core/src/lib.rs b/tracker/agb-midi-core/src/lib.rs index 6aefa9e8..ff27dad0 100644 --- a/tracker/agb-midi-core/src/lib.rs +++ b/tracker/agb-midi-core/src/lib.rs @@ -98,7 +98,12 @@ pub fn parse_midi(midi_info: &MidiInfo) -> TokenStream { for sample in sf2.get_sample_headers() { let sample_start = sample.get_start() as usize; - let sample_end = sample.get_end() as usize; + let mut sample_end = sample.get_end() as usize; + let sample_loop_end = sample.get_end_loop() as usize; + + if sample_loop_end > sample_start && sample_loop_end < sample_end { + sample_end = sample_loop_end; + } let sample_data = &sf2_data[sample_start..sample_end];