MajicDesigns/MD_MIDIFile

big gap when running in looping mode

robmint opened this issue · 1 comments

Thank you for sharing your useful lib.

I am running the library on Arduino Uno with some HID USB firmware to make the Uno appear as a midi device.

The main MCU is running your lib and reading midi from SD card and playing it in looping mode. I am using your example katzen perc fullvel.mid file.

The issue i'm having is a big gap in the playback after the file finishes (about 10 seconds). I'm trying to achieve a seamless looping of the midi file.

I have tried with other midi files and it seems the gap is not always so long, but there is always a gap of some length.

I've used your example code MD_MIDIFile_Loop.

I am using a midi monitor tool display all the midi messages as they are received. From the beginning:

11:46:34.160	From MIDI Exercycle	Control	1	Bank Select	0
11:46:34.161	From MIDI Exercycle	Control	1	Bank Select (fine)	0
11:46:34.162	From MIDI Exercycle	Program	1	0
11:46:34.163	From MIDI Exercycle	Control	1	Pan (coarse)	64
11:46:34.164	From MIDI Exercycle	Control	1	Chorus Send Level	0
11:46:34.165	From MIDI Exercycle	Control	1	Channel Volume (coarse)	100
11:46:34.166	From MIDI Exercycle	Control	1	Reverb Send Level	0
11:46:34.353	From MIDI Exercycle	Note On	1	62	127
11:46:34.446	From MIDI Exercycle	Note Off	1	62	64
11:46:34.738	From MIDI Exercycle	Note On	1	64	127
11:46:34.831	From MIDI Exercycle	Note Off	1	64	64
11:46:35.123	From MIDI Exercycle	Note On	1	65	127
11:46:35.217	From MIDI Exercycle	Note Off	1	65	64
11:46:35.509	From MIDI Exercycle	Note On	1	67	127
11:46:35.602	From MIDI Exercycle	Note Off	1	67	64
11:46:35.894	From MIDI Exercycle	Note On	1	69	127
11:46:35.987	From MIDI Exercycle	Note Off	1	69	64
11:46:37.049	From MIDI Exercycle	Note On	1	60	127
11:46:37.143	From MIDI Exercycle	Note Off	1	60	64
11:47:58.915	From MIDI Exercycle	Program	15	0
11:48:25.162	From MIDI Exercycle	Control	13	Foot Control (coarse)	4
11:48:25.165	From MIDI Exercycle	Control	13	Controller 24	8
11:48:28.429	From MIDI Exercycle	Note Off	1	101	114
11:48:28.588	From MIDI Exercycle	Note Off	1	0	0
11:48:28.639	From MIDI Exercycle	Note Off	1	0	0
11:48:41.806	From MIDI Exercycle	Note Off	1	64	0
11:48:41.956	From MIDI Exercycle	Note Off	1	0	0
11:48:41.967	From MIDI Exercycle	Note Off	1	100	0
11:48:42.113	From MIDI Exercycle	Note Off	1	0	120
11:48:45.501	From MIDI Exercycle	Note Off	1	127	58
11:48:45.687	From MIDI Exercycle	Note On	1	64	127
11:48:45.780	From MIDI Exercycle	Note Off	1	64	64
11:48:46.072	From MIDI Exercycle	Note On	1	65	127
11:48:46.165	From MIDI Exercycle	Note Off	1	65	64
11:48:46.457	From MIDI Exercycle	Note On	1	67	127
11:48:46.550	From MIDI Exercycle	Note Off	1	67	64
11:48:46.843	From MIDI Exercycle	Note On	1	69	127
11:48:46.936	From MIDI Exercycle	Note Off	1	69	64
11:48:47.997	From MIDI Exercycle	Note On	1	60	127
11:48:48.092	From MIDI Exercycle	Note Off	1	60	64
11:48:48.371	From MIDI Exercycle	Note Off	1	101	114
11:48:48.531	From MIDI Exercycle	Note Off	1	0	0
11:48:48.582	From MIDI Exercycle	Note Off	1	0	0
11:49:01.749	From MIDI Exercycle	Note Off	1	64	0
11:49:01.898	From MIDI Exercycle	Note Off	1	0	0
11:49:01.909	From MIDI Exercycle	Note Off	1	100	0
11:49:02.056	From MIDI Exercycle	Note Off	1	0	120
11:49:05.443	From MIDI Exercycle	Note Off	1	127	58
11:49:05.629	From MIDI Exercycle	Note On	1	64	127
11:49:05.722	From MIDI Exercycle	Note Off	1	64	64
11:49:06.014	From MIDI Exercycle	Note On	1	65	127
11:49:06.108	From MIDI Exercycle	Note Off	1	65	64
11:49:06.400	From MIDI Exercycle	Note On	1	67	127
11:49:06.493	From MIDI Exercycle	Note Off	1	67	64
11:49:06.785	From MIDI Exercycle	Note On	1	69	127
11:49:06.878	From MIDI Exercycle	Note Off	1	69	64
11:49:07.939	From MIDI Exercycle	Note On	1	60	127
11:49:08.034	From MIDI Exercycle	Note Off	1	60	64
11:49:08.314	From MIDI Exercycle	Note Off	1	101	114
11:49:08.474	From MIDI Exercycle	Note Off	1	0	0
11:49:08.524	From MIDI Exercycle	Note Off	1	0	0
11:49:21.692	From MIDI Exercycle	Note Off	1	64	0
11:49:21.841	From MIDI Exercycle	Note Off	1	0	0
11:49:21.852	From MIDI Exercycle	Note Off	1	100	0
11:49:21.998	From MIDI Exercycle	Note Off	1	0	120
11:49:25.386	From MIDI Exercycle	Note Off	1	127	58
11:49:25.572	From MIDI Exercycle	Note On	1	64	127
11:49:25.665	From MIDI Exercycle	Note Off	1	64	64
11:49:25.957	From MIDI Exercycle	Note On	1	65	127
11:49:26.050	From MIDI Exercycle	Note Off	1	65	64
11:49:26.342	From MIDI Exercycle	Note On	1	67	127
11:49:26.436	From MIDI Exercycle	Note Off	1	67	64
11:49:26.728	From MIDI Exercycle	Note On	1	69	127
11:49:26.821	From MIDI Exercycle	Note Off	1	69	64
11:49:27.882	From MIDI Exercycle	Note On	1	60	127
11:49:27.977	From MIDI Exercycle	Note Off	1	60	64
11:49:28.256	From MIDI Exercycle	Note Off	1	101	114
11:49:28.416	From MIDI Exercycle	Note Off	1	0	0
11:49:28.467	From MIDI Exercycle	Note Off	1	0	0
11:49:41.634	From MIDI Exercycle	Note Off	1	64	0
11:49:41.783	From MIDI Exercycle	Note Off	1	0	0
11:49:41.795	From MIDI Exercycle	Note Off	1	100	0
11:49:41.941	From MIDI Exercycle	Note Off	1	0	120
11:49:45.328	From MIDI Exercycle	Note Off	1	127	58
11:49:45.514	From MIDI Exercycle	Note On	1	64	127
11:49:45.608	From MIDI Exercycle	Note Off	1	64	64
11:49:45.900	From MIDI Exercycle	Note On	1	65	127
11:49:45.993	From MIDI Exercycle	Note Off	1	65	64
11:49:46.285	From MIDI Exercycle	Note On	1	67	127
11:49:46.378	From MIDI Exercycle	Note Off	1	67	64
11:49:46.670	From MIDI Exercycle	Note On	1	69	127
11:49:46.763	From MIDI Exercycle	Note Off	1	69	64
11:49:47.824	From MIDI Exercycle	Note On	1	60	127
11:49:47.919	From MIDI Exercycle	Note Off	1	60	64
11:49:48.199	From MIDI Exercycle	Note Off	1	101	114
11:49:48.359	From MIDI Exercycle	Note Off	1	0	0
11:49:48.409	From MIDI Exercycle	Note Off	1	0	0

Any ideas?

The library does not add or remove any delays. So unless the application is adding a delay in the code, it plays the file as it reads it with a small overhead when the file is started. The delay must be in the actual file. You should edit the MIDI file using an appropriate tool to remove any quiet time at the start or end.