SYSEX STORAGE IN A MIDI FILE HAS A LENGTH
Be aware what you are calling "hardware" messages are the bytes that would appear in an actual MIDI transmission on a MIDI cable. What you are calling "software" messages include an extra length indicator after the initial F0, but this only exists as part of the MIDI file specification. In a MIDI file it is important to know in advance how many bytes are part of the System Exclusive message, so a MIDI file includes a "variable-length quantity" value to indicate how many bytes follow that are part of the System Exclusive message. Be aware that a variable-length quantity can be 1 to 4 bytes. The high bit of the byte indicates if there are more bytes in the variable length quantity. The lower seven bits of each of the variable-length quantity bytes are concatenated to form the actual length value. This variable-length quantity only appears in the MIDI file, the actual System Exclusive message that is transmitted on the MIDI output port does not contain the variable-length quantity. In the
Standard MIDI Files spec, see PDF page 4 (printed page 2) for how variable-length quantities work, and see PDF page 8 (printed page 6) for how System Exclusive messages are stored in a MIDI file.
SYSEX MANUFACTURER ID
Be aware that System Exclusive messages always contain a Manufacturer ID, it is right after the F0. In your examples, 41 is for Roland, 43 is for Yamaha, and 7E is for a Non-Real Time Universal System Exclusive messages. (Universal System Exclusive messages are defined by MIDI standards instead of a manufacturer.) Be aware that Manufacturer IDs can be 1 byte or 3 bytes. If the first byte is 00 then two more bytes follow in the Manufacturer ID. In the
MIDI 1.0 specification, see PDF pages 39, 40, and 83 to 85 (printed pages 34, 35, and T-11 to T-13). Also see the
Manufacturer ID list on this website.
SYSEX DEVICE ID
In all of your examples, the next byte after the Manufacturer ID (what you are calling a "model ID" ), is actually a "Device ID" or "Device Number". Be aware that each manufacturer can put whatever they want in their System Exclusive messages after their Manufacturer ID, and the next thing after the Manufacturer ID might not always be a Device ID. But for GM, GS, and XG messages a Device ID does appear after the Manufacturer ID.
The purpose of a Device ID is in case you need to chain together multiple devices that are the exact same manufacturer and model, you can set them to different Device IDs via their control panels, then you can send System Exclusive messages to them independently by putting their corresponding Device ID in the sysex message. There's no "list" of Device IDs, because the user can change the Device ID of their device to whatever they want. You are correct that if you are just trying to tell if the System Exclusive message is a GM, GS, or GX reset message, you don't really care what the device ID is, you should just confirm the rest of the message matches the expected reset message. (Although if you really want to check if the Device ID is in a valid range, it looks like the GM, GS, and XG formats have different allowed ranges for Device IDs.)
Roland calls them "Device IDs" and uses values from hex 00 to 1F. I think hex 10 is the default for Roland GS devices, at least I know it is the default in the Roland Sound Canvas SC-55, the first device to use Roland GS. In the
Roland SC-55 manual (from the
Roland Manual Archive), page 53 describes Device IDs displayed on the control panel can be from 1 to 32, with a default of 17. Page 72 describes the format of Roland System Exclusive messages, and describes the hex format of the Device ID is 00 to 1F, which is the Device ID shown on the control panel minus 1. (The control panel Device ID 1 is hex 00 in sysex, and so on.) This description says that devices that only respond to one MIDI channel would usually use the same number for their Device ID: A device that responds to a single channel from channel 1 to 16 would use the matching control panel Device ID 1 to 16 or hex 00 to 0F in sysex. Devices that can respond to multiple MIDI channels can use a control panel Device ID from 17 to 32 or hex 10 to 1F in sysex.
Yamaha calls them "Device Numbers", and they can be from hex 10 to 1F, which presumably correspond to Device Number 1 to 16 on the control panel of the device. There is no mention of trying to match them to MIDI channel numbers, so I assume Yamaha's Device Numbers are never related to MIDI channels. Take a look at the
manual for the Yamaha MU80 (from the
Yamaha Manual Library), the first device to use Yamaha XG. The control panel Device Number setting is on the bottom of page 41 and top of page 42. It is 1 to 16, or "all" to indicate it doesn't care what the incoming device number is. The XG System On System Exclusive message is mentioned on page 124. The device number is listed as hex 1n. It doesn't specifically mention how this maps to the control panel Device Number, but I assume control panel Device Numbers 1 to 16 match sysex hex 10 to 1F.
For System Exclusive messages defined by MIDI standards, they're called Device IDs, and can presumably be any value from hex 00 to 7F, but 7F is the "all device" ID, meaning a device should always respond no matter what its Device ID is. In the
MIDI 1.0 standard, Device IDs are mentioned on PDF page 40 (printed page 35). It mentions the Device ID was previously referred to as a "channel byte", but says the Device ID should usually refer to a physical device and not a MIDI channel or virtual device inside a physical device, but there can be exceptions if this makes sense. It only mentions the value hex 7F as being the special "all devices" value, so I presume devices are allowed to use any other values from 00 to 7E as their Device ID for MIDI standard Universal System Exclusive messages if they want to.
SYSEX MODEL IDS
Also, just for your information, be aware that sysex messages usually have some kind of bytes to identify the model or version of the device, but there's not a standard position they will be in for every sysex message. A particular device will look for matching Manufacturer ID byte(s) and Model ID bytes, and possibly Device ID byte to confirm the sysex message is one it should listen to. However, be aware that a device can respond to more than one kind of Model ID, if it can understand the meaning of another model's messages. Yamaha and Roland devices often have a specific model ID but also respond to a generic "GX" or "GS" model ID for the GX or GS features they support. This lets all GX and GS devices use the same types of sysex messages for their GX and GS features.
In fact, the MIDI spec (
MIDI 1.0 spec, PDF page 39 / printed page 34) says a device can respond to another manufacturer's messages if that would be useful, but a manufacturer can't define modified or new message types under another manufacturer's ID. Also interesting is that spec apparently requires manufacturers to publish the format of their System Exclusive messages so that anyone can understand and use them if they want to. Older MIDI devices often have detailed descriptions in the manual of all of their MIDI messages including all the manufacturer System Exclusive messages they use. Unfortunately, manuals for modern MIDI devices often do not describe the format of their proprietary System Exclusive messages which saddens me.