Midi explanation in Hex for those asking how to edit .ini files

Visit www.midi.org for the full spec but it’s all in binary.

Here’s an explanation in hex, as that’s what’s used by midibox.

Also, what I call a ‘Command’, Midibox refers to as the 'Status byte".

I think ‘Command’ makes things more understandable.

MIDI Commands in HEX

All Midi commands are higher than 7f Hex (127 decimal, 01111111 binary). They start with 80 Hex (128 decimal, 10000000 binary), which means that a command always has bit 7 set ( 1 0000000 binary)and the associated values that follow the command do not have bit 7 set ( 0 11111111 binary). This is how midi primarily distinguishes between commands and data.

You don’t need to know that to edit the .ini files.

The first byte of all midi commands is divided into the command half and the midi channel half.

NOTE OFF (still in use for older gear mainly, now most devices use NOTE ON with velocity = 0 instead)

8X NN VV

8 is the command half for a NOTE OFF

X is the midi channel half - range 0-F (0-15 decimal)

NN is the NOTE NUMBER - range 00-7F (0-127 decimal)

VV is the notes VELOCITY - range 00-7f (0-127 decimal)

NOTE ON

9X NN VV

9 is the command half for a NOTE ON

X is the midi channel half - range 0-F (0-15 decimal)

NN is the NOTE NUMBER - range 00-7F (0-127 decimal)

VV is the notes VELOCITY - range 00-7f (0-127 decimal)

(VELOCITY vaue 0 (zero) is now used for NOTE OFF)

POLYPHONIC PRESSURE (some call it AFTERTOUCH)

AX NN VV

A is the command half for a POLYPHONIC AFTERTOUCH

X is the midi channel half - range 0-F (0-15 decimal)

NN is the NOTE NUMBER - range 00-7F (0-127 decimal)

VV is the AFTERTOUCH AMOUNT - range 00-7f (0-127 decimal)

CONTINUOUS CONTROLLER (CC for short)

BX CC 7F

B is the command half for a CONTINUOUS CONTROLLER

X is the midi channel half - range 0-F (0-15 decimal)

CC is the CONTROLLER NUMBER - range 00-7F (0-127 decimal)

VV is the CONTROLLER AMOUNT - range 00-7f (0-127 decimal)

PROGRAM CHANGE

CX PP

C is the command half for a PROGRAM CHANGE

X is the midi channel half - range 0-F (0-15 decimal)

PP is the PROGRAM NUMBER - range 00-7F (0-127 decimal)

CHANNEL PRESSURE (some call it AFTER-TOUCH)

DX VV

D is the command half for a CHANNEL AFTERTOUCH

X is the midi channel half - range 0-F (0-15 decimal)

VV is the AFTERTOUCH AMOUNT - range 00-7f (0-127 decimal)

Note : Thorsten comments the use of this midi command as 3 bytes.

“D. .. .. (Channel Aftertouch) Example: D0 30 7F @OnOff  (MIDIbox sends D0 30 vv)”

This might cause problems with some gear as it should be 2 bytes.

There should be no note associated with this command.

It affects all notes being held down on the same midi channel.

PITCH BEND

EX B1 B2

E is the command half for a PITCH BEND

X is the midi channel half - range 0-F (0-15 decimal)

B1 is the first half of the PITCHBEND AMOUNT - range 00-7F (0-127 decimal)

(refered to as the least significant byte)

B2 is the second half of the PITCHBEND AMOUNT - range 00-7F (0-127 decimal)

(refered to as the most significant byte)

Note: when B1 and B2 are both 40 hex (64 decimal), that is centered, no pitchbend.

                Note: Thorsten works this out for you in the firmware, so just use range 0-7F (0-127 decimal)

There are more midi commands, but this should help get you started.

bassman

Nice job Bassman! That should be added to the Wiki.

Yep, that is good doco, definitely should be on the wiki instead of here :slight_smile: (Cut from here, paste to the wiki, format it up, and paste the link to the wiki back in here)

Probably worth mentioning that the ‘commands’ are usually referred to as the ‘status byte’ so that people can relate your plain-english explanation to the other technobabble they find around the net. And a link to The Brainwashing Centre at the end for those who need more: http://home.roadrunner.com/~jgglatt/tech/midispec.htm

I amended, with your suggestion re: status byte. Quite right.

I would paste it to the wiki, if I could figure out how. I have it ready to paste.

Oh… there’s ‘technobabble’ aplenty at www.midi.org:smiley:

Hopefully, it will help some, I see the question often enough, maybe it’ll be a few less replies for stryd, I notice he’s always answering that one. Amazing how many people don’t understand midi!

I also found this cool page from Univ. NSW australia.

http://www.phys.unsw.edu.au/jw/notes.html

might be useful for the wiki too?

bassman

Yah that link is nice, I like the pics especially

The wiki should be pretty easy… assuming you’re already logged in (same username/pass as the forum) then you can edit any existing page such as this one http://www.midibox.org/dokuwiki/midi_specification … Or, you can make your own URL like http://www.midibox.org/dokuwiki/simple_midi_specification and when you visit it, it’ll tell you that it doesn’t exist yet, and you can create it. Just, don’t forget to edit some other page to link to your new one :slight_smile:

ok, done that, yet another syntax to figure out, standardisation is boring! ;D

I put it in About : References : Midi

http://www.midibox.org/dokuwiki/simple_midi_specification

bassman

LMAO ohhh yeh. I use a couple of firefox addons to take care of most BBCode/wiki tagging, and use the GUIs wherever possible… but the various different ‘code’ tags ALWAYS get me! dammit!

I added another link to it in the big midi spec page too, might save some people a very heavy read :wink:

Thanks!! Doco is good!

NOTE OFF (not used anymore, but has to be accounted for)

8X NN VV

NOTE ON

9X NN VV

(VELOCITY vaue 0 (zero) is now used for NOTE OFF)

I would be interested to know when the Note Off Status Byte (8X) was made obsolete. I haven’t seen anything about that in various documentations but I admit I don’t have access to the very latest official Midi Specification.

I’m always using the Note Off Status Byte since to me it looks better and is easier to spot.

Err OK obviously I’m not the only one that thought that :smiley:

The NOTE OFF is still used in older gear, and you can still use it now, so it’s not obselete. But when ‘RUNNING STATUS’ came in around '91, NOTE ON with Velocity zero started, as it allowed the same status byte to be used (or rather omitted in running status).

Running Status allows the status bit to be left out and just the note number and velocity to be sent. A different status byte would interupt running status. It allowed more data transmission to be squeezed out of the midi baud rate.

If you are just using a keyboard and a module or two, it’s of no real consequence, but if you use computer software such as Cubase, Cakewalk etc, and have 8 midi ports and 20 sound modules playing away, you’ll appreciate the advantage.

Access to official midi specifications is freely available at www.midi.org

bassman

NOTE OFF (not used anymore, but has to be accounted for)

8X NN VV

Maybe better to say “(many devices use NOTE ON with velocity = 0 instead of NOTE OFF)”?

I think this may point out a small issue in MIDIboxes that receive and respond to MIDI In. Do they understand that 8X NN VV and 9X NN 00 both do the same thing? I’ve never used the MIDI In on a MIDIbox for anything so I just don’t know.  Does MIOS translate one of those to the other?  ???

For that matter, does MIOS handle running status for MIDI In or create running status on MIDI Out? I’m guessing yes, at least for handling running status on MIDI In.

(Yes I know I’m being lazy and I could go find the answers. But since I don’t care about the answers at the moment let’s just say I’m asking for the benefit of someone who might not have thought of the questions. If someone knows the answers off-hand that is great but otherwise just leave it for someone who needs this information to go find it.)

Amendment duly noted, Jim.

Midibox does not send 80 NN VV (NOTE OFF), but if it receives it, it is converted into a NOTE ON with velocity 0.

However I see no sign of any use of ‘running status’ to transmit or accounting for receiving ‘running status’ events. I’m not sure if ‘running status’ bytes are merged and re-sent.

I would suggest, that users needing to use the Merge function and/or the Midi In for remote, should look in the item that is sending, to see if ‘running status’ can be turned off somewhere.

I think, the code looks like it should ignore midi events that do not have their status bytes first.

Just my opinion from looking through the relevant code, quickly.

Probably TK can enlighten us further!

bassman

Midibox does not send 80 NN VV (NOTE OFF)

The Midibox, at least the MIDIO128, does send Note Off. Here’s a clip of my INI file.

##########################################
# Pin  # On Evnt # Off Evnt # Behaviour #
##########################################
    1 =  90 2F 7F  80 2F 00  @OnOff # B2  Great
    2 =  90 2E 7F  80 2E 00  @OnOff # A#2 Great
    3 =  90 2D 7F  80 2D 00  @OnOff # A2  Great

And here’s the response from MIDI-OX

0000658A  9  --    90    2F    7F    1  B  2 Note On    
000065FA  9  --    80    2F    00    1  B  2 Note Off   
00007977  9  --    90    2E    7F    1  Bb 2 Note On    
000079E7  9  --    80    2E    00    1  Bb 2 Note Off   
00007C2E  9  --    90    2D    7F    1  A  2 Note On    
00007CCB  9  --    80    2D    00    1  A  2 Note Off 

MIDIO128 version 2.2b

Well ok, Per S, you can get NOTE OFF to happen by editing the .ini file to deliberately send NOTE OFF.

I didn’t really mean that you can’t get it to happen.

However, MIDIO128 will convert incoming NOTE OFF status bytes to NOTE ON velocity 0.

So try merging your core through another core, using the Midi In Merge. You’ll find your NOTE OFF have gone, they’ll be NOTE ON.

Plus, if you ever want to use midi input to trigger events by using ‘Forward Input to Output’, and decide to use Note on/off messages, you’ll find that MIDIO128, after converting incoming NOTE OFF status bytes to NOTE ON velocity 0, will not find a match in your MIDIO Presets.

The MIDIO128 .ini file clearly shows NOTE OFF (80 NN VV) as not supported for midi in.

I’m not sure it’s a good idea to use NOTE OFF anymore, especially just because it looks neat when monitored. Sooner or later, there’ll be trouble, mainly for those that my original post was trying to help.

But, of course, some older (and maybe more desirable) equipment may well work better with NOTE OFF being sent.

bassman

However, MIDIO128 will convert incoming NOTE OFF status bytes to NOTE ON velocity 0.

True

So try merging your core through another core, using the Midi In Merge. You’ll find your NOTE OFF have gone, they’ll be NOTE ON.

I have three cores chained with Midi Merge enabled. It looks like this:

ID00–>ID02–>ID01–>MIDI In on the PC.

Here’s the INI file for ID02

#########################################
# Pin  # On Evnt # Off Evnt # Behaviour #
##########################################
    1 =  93 2F 7F  83 2F 00  @OnOff # B2  Solo
    2 =  93 2E 7F  83 2E 00  @OnOff # A#2 Solo
    3 =  93 2D 7F  83 2D 00  @OnOff # A2  Solo

The result after merging in core ID01 and sent to the PC

00047088  9  --    93    2F    7F    4  B  2 Note On      
0004712C  9  --    83    2F    00    4  B  2 Note Off     
0004756F  9  --    93    2E    7F    4  Bb 2 Note On      
00047630  9  --    83    2E    00    4  Bb 2 Note Off     
000478DC  9  --    93    2D    7F    4  A  2 Note On      
0004795E  9  --    83    2D    00    4  A  2 Note Off   

The Core Midi Merge function is happily forwarding the Note Off (8X). In my opinion this is the correct way, a merge function shouldn’t change anything, it should just forward what’s received.

It was not my intention to start an animated discussion but merely point out that the Note Off (8X) Status Byte is still, according to the latest MIDI Spec, a valid Status Byte, and is not (yet) obsolete.

MIOS decodes incoming MIDI events, so that the user application doesn’t need to take care about the running status - USER_MPROC_NotifyReceivedEvent will always get the complete event. This not only simplifies the programming of a MIDI processor, but also the merging of an incoming and an internally generated MIDI stream (the user application isn’t able to send a new event so long an incoming event has been forwarded completely)

Note On with velocity 0 -> Note off conversion has to be done at application side (see also this example).

With enabled MIDI merger, the discarded status byte of an incoming MIDI event which gets use of running status feature will be added to by MIOS before the event will be forwarded. This isn’t an optimal solution, but some years ago I didn’t see a need for this, meanwhile I would like to add such a feature to MIOS (once I find the time…). It will require a timer function which resets the running status after some time (e.g. after one second) to ensure, that a MIDI receiver sooner or later receives the running status if the MIDI cable has been disconnected/connected during runtime.

Best Regards, Thorsten.

Yes you’re right Per S, I was more concerned with what MIOS does with ‘running status’ and got mixed up. It seems that ‘running status’ messages are converted to ‘full midi’ messages by having their status bytes added on before re-sending. Thanks TK, for clearing that up.

Anyway, no-one is suggesting NOTE OFF is obsolete. It’s perfectly valid.

However, if you use incoming midi to trigger events, it would be prudent not to use NOTE OFF messages for this, as most of the applications convert this to NOTE ON vel. 0, so when the app. searches for a match with NOTE OFF, it probably won’t find it.

At least the situation is clear now, and there shouldn’t be any trouble whatever messages are used.

bassman

However, if you use incoming midi to trigger events, it would be prudent not to use NOTE OFF messages for this, as most of the applications convert this to NOTE ON vel. 0, so when the app. searches for a match with NOTE OFF, it probably won’t find it.

That’s why you should do it like TK did - use an OR statement and treat both messages the same way. Software may (almost) always convert to note on vel 0, but hardware does not.

This is a most enlightening discussion!

I’ve looked at the code for MIDIIO128. It converts a MIDI In Note Off message to a Note On with velocity 0:

MIDIO_MIDI_Scan
	;; if note Off event has been received, convert it to Note On with velocity == 0
	movf	MIOS_PARAMETER1, W
	andlw	0xf0
	movwf	TMP2
	xorlw	0x80
	bnz	MIDIO_MIDI_Scan_NoNoteOff
MIDIO_MIDI_Scan_NoteOff
	movlw	0x90
	iorwf	MIOS_PARAMETER1, F
	clrf	MIOS_PARAMETER3
MIDIO_MIDI_Scan_NoNoteOff

Therefore it should be pointed out that in configuring the Input portion of the MIDIIO128 configuration table, NOTE OFF (0x8n) should not be used because any NOTE OFF that is received will be converted to NOTE ON with velocity 0. A NOTE OFF in the Input section of the configuration table will never be selected by MIDI Input.

You can use NOTE OFF in the Output portion of the MIDIIO128 configuration table and whatever you use will appear unaltered on the MidiBox MIDI Out Port. However, it is probably better to use NOTE ON with velocity 0 rather than NOTE OFF for consistency with the Input section and for greater efficiency if MIOS were to support running status for MIDI Out in the future. (MIOS does handle running status in the MIDI In.)

Hope I got all that right.

That is exactly the way I see it, Jim. The code you found is quite self explanatory. And TK cleared up what I was suspecting in MIOS.

I thought it best to point those, who need to know how to edit their .ini files, away from using NOTE OFF and save them from any possible puzzle.

bassman