{"id":1407,"date":"2014-04-15T09:07:47","date_gmt":"2014-04-15T09:07:47","guid":{"rendered":"https:\/\/ibex.tech\/resources\/?p=1407"},"modified":"2022-02-18T15:05:16","modified_gmt":"2022-02-18T15:05:16","slug":"midi-comms","status":"publish","type":"post","link":"https:\/\/ibex.tech\/resources\/geek-area\/communications\/midi\/midi-comms","title":{"rendered":"MIDI Comms"},"content":{"rendered":"<h4>\nGood resources<br \/>\n<\/h4>\n<p>\n<a href=\"http:\/\/hinton-instruments.co.uk\/reference\/midi\/protocol\/index.htm\">hinton-instruments.co.uk\/reference\/midi\/protocol\/<\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/www.midi.org\/techspecs\/midimessages.php\">midi.org\/techspecs\/midimessages.php<\/a>\n<\/p>\n<h4>\nCommunications Overview<br \/>\n<\/h4>\n<p>\nCommand bytes\n<\/p>\n<p style=\"margin-left: 40px;\">\nAlways 128 or greater (0x80 to 0xFF)\n<\/p>\n<p style=\"margin-left: 40px;\">\n\u200b\u200bIncludes things like note on, note off, pitch bend, etc.\n<\/p>\n<p>\nData bytes\n<\/p>\n<p style=\"margin-left: 40px;\">\nAlways less than 127 (0x00 to 0x7F)\n<\/p>\n<p style=\"margin-left: 40px;\">\nIncludes things like the pitch of the note to play, the velocity, or loudness of the note, and amount of pitch bend, etc.\n<\/p>\n<p>\nMIDI packets\n<\/p>\n<p style=\"margin-left: 40px;\">\nAt least two bytes:-&nbsp;a status\/command byte and a data byte.\n<\/p>\n<p style=\"margin-left: 40px;\">\nMost common MIDI messages have three bytes:-&nbsp;a status\/command byte followed by two data bytes. &nbsp;In a typical MIDI message&nbsp;this comprises of the action (note on, note off, pitch bend, etc), the pitch (musical pitch) and the velocity (how loud the sound should&nbsp;play).\n<\/p>\n<h5>\nCommands<br \/>\n<\/h5>\n<pre>\r\n<code>\r\nValue (Hex) \tCommand \tData bytes\r\n0x80-0x8F \tNote off \t2 (note, velocity)\r\n0x90-0x9F \tNote on \t2 (note, velocity)\r\n0xA0-0xAF \tKey Pressure \t2 (note, key pressure)\r\n0xB0-0xBF \tControl Change \t2 (controller no., value)\r\n0xC0-0xCF \tProgram Change \t1 (program no.)\r\n0xD0-0xDF \tChannel Pressure \t1 (pressure)\r\n0xE0-0xEF \tPitch Bend \t2 (least significant byte, most significant byte)\r\n<\/code><\/pre>\n<p>\nThe 0x0 to 0xF range is for the channel number, e.g. 0xB0 is Control change for channel 1, 0xB1 is addressing&nbsp;channel 2, etc.\n<\/p>\n<h4>\nIndividual Commands<br \/>\n<\/h4>\n<p>\n<strong><em># = MIDI channel number from 0x0&nbsp;to 0xF (0 &#8211; 15) in the command bytes below<\/em><\/strong>\n<\/p>\n<h5>\n0xB# 0x7B &#8211; All notes off<br \/>\n<\/h5>\n<p>\n0x9# | 0x7B | 0x00\n<\/p>\n<p>\n\u200bClears all playing notes. &nbsp;Can be very handy during development!\n<\/p>\n<h5>\n0x9# &#8211; Note On<br \/>\n<\/h5>\n<p>\nIndicates that a particular note should be played &#8211;&nbsp;the note should starts sounding.\n<\/p>\n<p>\n0x9# | Note Number | Velocity\n<\/p>\n<p>\nNote Number\n<\/p>\n<p style=\"margin-left: 40px;\">\nThere are 128 possible notes on a MIDI device, numbered 0 to 127. &nbsp;Middle C is note number 60.\n<\/p>\n<p>\nVelocity\n<\/p>\n<p style=\"margin-left: 40px;\">\nA value from 0 to 127. Indicates how much force the note should be played with (127 = maximum force). &nbsp;Default: 64 (0x40)\n<\/p>\n<p style=\"margin-left: 40px;\">\nIt&#39;s up to a MIDI device how it uses velocity information. Often it is used to tailor the VCA attack time and\/or attack level (and therefore the overall volume of the note).\n<\/p>\n<p style=\"margin-left: 40px;\">\nMIDI devices that can generate Note On messages, but don&#39;t implement velocity features, will transmit Note On messages with a preset velocity of 64.\n<\/p>\n<p style=\"margin-left: 40px;\">\nNote On messages which have a velocity of 0 are&nbsp;considered to actually be a Note Off messages, this &quot;trick&quot; having been created to take advantage of running status, so that Note Off message can be incorporated in a run of Note On messages\n<\/p>\n<p style=\"margin-left: 40px;\">\nA device which recognizes MIDI Note On messages must be able to recognize both a real Note Off as well as a Note On with 0 velocity (as a Note Off). There are many devices which&nbsp;generate real Note Off messages but&nbsp;many other devices thich use Note On with 0 velocity instead.\n<\/p>\n<p style=\"margin-left: 40px;\">\nEvery Note On should be followed by a respective Note Off message at some point. &nbsp;Even if the note&#39;s sound fades out before a Note Off for this note is received, at some later point a Note Off should be received. For example, if a MIDI device receives the following Note On:\n<\/p>\n<p style=\"margin-left: 40px;\">\nIf a device receives a Note On for a note which is already playing it is up to the device&nbsp;whether to add another layer of note playing sound or cut off the sound playing the preceding note and re-trigger the&nbsp;note.&nbsp;\n<\/p>\n<p>\nExample Note On Commands\n<\/p>\n<p style=\"margin-left: 40px;\">\n0x90 0x3C 0x40<br \/>\nNote On, \u200bMIDI channel 0, Middle C, velocity of 64\n<\/p>\n<p style=\"margin-left: 40px;\">\n0x90 0x3C 0x00<br \/>\nNote Off, MIDI channel 0, Middle C, velocity of 0 = Note Off\n<\/p>\n<h5>\n0x8# &#8211; Note Off<br \/>\n<\/h5>\n<p>\nNote Off can also be sent by sending Note On with velocity = 0\n<\/p>\n<p>\nIndicates that a particular note should be released.\n<\/p>\n<p>\n0x8# | Note Number | Velocity\n<\/p>\n<p>\nNote number\n<\/p>\n<p style=\"margin-left: 40px;\">\n0 to 127\n<\/p>\n<p>\nVelocity\n<\/p>\n<p style=\"margin-left: 40px;\">\nA&nbsp;value from 0 to 127 which&nbsp;indicates how quickly the note should be released (127 = fastest). Default: 64 (0x40)\n<\/p>\n<p style=\"margin-left: 40px;\">\nIt&#39;s up to a MIDI device how it uses velocity information.\n<\/p>\n<p style=\"margin-left: 40px;\">\nMIDI devices which generate Note Off messages&nbsp;but don&#39;t implement velocity features&nbsp;will transmit Note Off messages with a preset velocity of 64.\n<\/p>\n<p>\nExample Note Off Command:\n<\/p>\n<p>\n0x80 0x3C 0x40\n<\/p>\n<p style=\"margin-left: 40px;\">\nNote Off, MIDI Channel 0,&nbsp;Middle C, velocity of 64\n<\/p>\n<h5>\nRunning Status<br \/>\n<\/h5>\n<p>\nYou are allowed to omit the first command byte when sending multiple commands of the same type. For instance if you want to send multiple Note On commands you could send this:\n<\/p>\n<p>\n0x90 0x3C 0x7F<br \/>\n0x90 0x40 0x7F<br \/>\n0x90 0x43 0x7F\n<\/p>\n<p>\n\u200bor this:\n<\/p>\n<p>\n0x90&nbsp;0x3C&nbsp;0x7F&nbsp;0x40&nbsp;0x7F&nbsp;0x43&nbsp;0x7F\n<\/p>\n<p>\nIf a receiver see&#39;s a new byte after it assumes a command has finished it must assume that a new command of the same type is being sent.\n<\/p>\n<p>\nRunning status is only implemented for Voice Category messages (Status byte&nbsp;0x80 to 0xEF).\n<\/p>\n<h5>\n0xB# 0x79 &#8211; Reset All Controllers<br \/>\n<\/h5>\n<p>\n0x9# | 0x79 | 0x00\n<\/p>\n<p>\nAll controller values are reset to their default values.\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good resources hinton-instruments.co.uk\/reference\/midi\/protocol\/ midi.org\/techspecs\/midimessages.php Communications Overview Command bytes Always 128 or greater (0x80 to 0xFF) \u200b\u200bIncludes things like note on, note off, pitch bend, etc. Data bytes Always less than 127 (0x00 to 0x7F) Includes things like the pitch of the note to play, the velocity, or loudness of the note, and amount of pitch [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86],"tags":[],"class_list":["post-1407","post","type-post","status-publish","format-standard","hentry","category-midi"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/comments?post=1407"}],"version-history":[{"count":8,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1407\/revisions"}],"predecessor-version":[{"id":1416,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1407\/revisions\/1416"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/media?parent=1407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/categories?post=1407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/tags?post=1407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}