Just discovered the problem I believe, and it is the MIDI's. Specifically the divsion/Ticks Per Quarter note value I'm using for the timing, which is byte #13 & 14 in the MThd header. I'm using TPQ value of 96, which is not common at all. Some Midi player will handle odd TPQ values, others will not.
As a test I made a one note MIDI using my program, imported it into a MIDI program that would load it. Then exported that to a new MIDI file. That new MIDI file played fine in QB64-PE 3.14. Comparing the original and new files in a Hex editor, the only major change I could see is that the division value is different, 480 which is common value. So, I patched the silentnight.mid that won't load at bytes 13&14 to put in the new 480 division number instead (in hex), and the bad file then loaded and plays in QB64-PE 3.14, although very fast because of the new TPQ value.
So, I will have to use a correct TPQ value and then recalculate the duration values in the MIDI program to that so the notes will play at the right speed. So, if the new Ticks Per Quarter = 480, then a Whole Note, which is 4 quarter note beats ( 4 x TPQ), so that would be 1920 ticks (4x480). And so on. I'll get working on a fixed version, hopefully this will make valid MIDI's.
- Dav
As a test I made a one note MIDI using my program, imported it into a MIDI program that would load it. Then exported that to a new MIDI file. That new MIDI file played fine in QB64-PE 3.14. Comparing the original and new files in a Hex editor, the only major change I could see is that the division value is different, 480 which is common value. So, I patched the silentnight.mid that won't load at bytes 13&14 to put in the new 480 division number instead (in hex), and the bad file then loaded and plays in QB64-PE 3.14, although very fast because of the new TPQ value.
So, I will have to use a correct TPQ value and then recalculate the duration values in the MIDI program to that so the notes will play at the right speed. So, if the new Ticks Per Quarter = 480, then a Whole Note, which is 4 quarter note beats ( 4 x TPQ), so that would be 1920 ticks (4x480). And so on. I'll get working on a fixed version, hopefully this will make valid MIDI's.
- Dav