|
Post by mms on Apr 5, 2022 21:12:49 GMT
Hi John,
I am doing some testing in my program regarding multiple tracks. I created a test file having 16 tracks, and each track having 1 note (all 16 notes starting and stopping at same time). The SMF created will not play via my program, but I noticed after, same file will play using Windows Media Player.
Could I send you the SMF John, to test if it works in your software, and perhaps see if you can spot a problem when looking at the MIDI bytes?
Thanks
|
|
|
Post by JohnG on Apr 6, 2022 10:28:06 GMT
Yes, go ahead and forward it to me, I'll try to take a look at it ASAP.
JohnG.
|
|
|
Post by mms on Apr 6, 2022 12:03:15 GMT
Thanks John,
File sent.
|
|
|
Post by JohnG on Apr 7, 2022 11:30:07 GMT
A quick response.
The file loads okay in a variety of sequencing programs; Sekaiju, XGworks, SOL2 and Anvil Studio, and plays.
Playback: You put a GM System On message at 001:01:000 together with ALL the instrument allocations. On many playback instruments it can take up to 200ms to go through every (hardware) channel resetting the controllers to their default settings. (Remember some instruments, e.g. my Yamaha MU1000 and my Roland SC-8850, have up to four MIDI interfaces and are thus 4x16 channels.) So, it's always good practice to leave roughly half a beat (it will depend on tempo) between the GM reset and the instrument setups. SO, for instance, at 480 TPQN and 120 bpm I put the first instrument allocations at 001:01:240. (I've explained this in one of my later MIDI basics tutorials.)
A GM System On message should (according to the MIDI specification) set every channel to grand piano so there should be no need after it to allocate that. In my view, It's always better to put the instrument allocations e.g. Bank Select MSB, Bank Select LSB, followed a tick later by the Program Change message. Then follow with the controller message setup
GM reset sets Channel Volume to 127 by default, according to the spec. as well as Pan to 64.
Key signature is a meta event and, in all programs I've sued to date, goes in the master channel and is universal per MIDI port.
You have a second GM System On message in measure 2. This is not normal practise but isn't forbidden.
I'll try to find a bit of time today to make some alterations to the file you sent with what I believe to be "good practice", taken from both the MMA and the Yamaha XG specs.
JohnG.
|
|
|
Post by mms on Apr 7, 2022 11:58:43 GMT
Thanks John.
After your response, it "clicked" about GMReset, and other initializations taking time to execute. I added one more measure of 16 notes, and my program will sound the 2nd measure only.
So I guess the only puzzling thing for me, is why do all these programs play that file except mine? I will spend a bit of time, and think on it.
In the mean-time, I will await your properly "authored" file.
Thanks again!
p.s. These are the only 2 lines in my code that are relevant to playing the file.
ret = mciSendString("open currMIDI type sequencer alias currMIDI", 0&, 0, 0) ret = mciSendString("play currMIDI from " & PlayFromPos & " to " & PlayToPos, 0&, 0, 0)
Both calls return "0" which means they have executed "OK"
|
|
|
Post by JohnG on Apr 7, 2022 14:37:03 GMT
Here's a quickly revamped version of the file you sent me with the way I would do it according to the specs as far as I know them. I certainly don't claim that it's the only way, just my way. Test16TracksJLG.mid (1.07 KB) JohnG.
|
|
|
Post by mms on Apr 7, 2022 21:56:37 GMT
Thanks John,
I will try authoring my file (within my program) exactly as you do, and see if my program will play the file properly.
|
|
|
Post by mms on Apr 10, 2022 16:36:09 GMT
OK, so I added some "lead-in" time before any note-on commands in my code, and now the SMF file it creates plays the file correctly in my program. In parsing the MIDI file I sent you, and the MIDI file you sent me, there seems to be some sort of problem. The problem could be in my parser, OR, in my code that writes the MIDI file bytes. In my file bytes 38 to 100 seem like garbage, and in your file bytes 30 to 59 seem like garbage. If I understand correctly, MIDI players will ignore garbage bytes, and play correctly. Maybe that is the case here. Could you send a screen shot from your sequencing tool (as you sometimes do here) of bytes 38 and 100 (from mine), and bytes 30 to 59 (from yours) so I can see if it is a parser or authoring problem. With that info, I should be able to then continue with fixing my code to write a SMF according to "best practice" techniques as you describe. Thanks again
|
|
|
Post by JohnG on Apr 11, 2022 17:53:28 GMT
Hi,
Give me a day or so (a bit busy at the moment) and I'll get back to you on this issue. I should have a bit of spare time tomorrow afternoon.
JohnG.
|
|
|
Post by JohnG on Apr 12, 2022 16:33:24 GMT
Okay, this is what I see using the Yamaha XGworks sequencing program. The master track in your file looks like this: The master track as edited in XGworks looks as follows: Don't know if that's any help? JohnG.
|
|
|
Post by mms on Apr 13, 2022 3:38:49 GMT
Yes John that helps a lot.
I think anyway my code to write the MIDI file is OK, because I am seeing from your screenshots, exactly what I was intending to write in the master track, and in the order in which I wrote those events.
This, combined with the fact that the MIDI also plays correctly, gives another reason to believe code OK.
The only thing I am not sure about is, the first event after the Tempo Event is supposed to be a Meta Sequence Number Event with an assigned value of "1"
Your screenshots show Meta Evnt, but does not say it is a Sequence Number, but does show "00 01" in Value 2 which is what I had assigned.
It is starting at this event (Meta Evnt), that my Parser starts reporting garbage, but corrects itself at the Meta Sequence Name Event. From there on in, it reports correctly all remaining events in the Master Track, as well as the 16 Music Tracks.
This means to me I either I have a problem with the way I am writing the Meta Sequence Number Event, or it is Parser problem, and I will have to fix code there.
Somewhere, I had a small hex-editor utility that might help also to confirm I am sending bytes in correct order in this problem area. I can't find it on this computer, but will check on my old laptop.
Debugging is not fun, but at least you helped pin-point the problem, That will keep me busy through the weekend I'm sure.
Thanks again John!
|
|
|
Post by mms on Apr 18, 2022 12:07:06 GMT
An easy fix Turns out the problem was with my Parser only; fixed code, and Parser now functions properly. Now to continue on with fixing the order/location of my SMF synth "set-up" commands.
|
|
|
Post by JohnG on Apr 19, 2022 11:21:49 GMT
Excellent, MMS.
|
|