generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: TOO LONG OF TITLE!!!

Previous Thread :: Next Thread 
supremechloe is not online. supremechloe
Joined: 14 Apr 2012
Total Posts: 1624
20 Aug 2013 12:20 PM
Essentials of the MIDI protocol
--------------------------------------------------------------------------------


The MIDI protocol which transfers musical information between keyboards and synthesizers, etc. is described here.

Hexadecimal numbers

You should become familiar with hexadecimal numbers to understand better the organization of the MIDI protocol. Here is a basic review:

The symbol 165 is a shorthand representation of a particular number. More specifically, 165 can be represented by:
165 = 1 x 102 + 6 x 101 + 5 x 100

I will write 16510 to mean the number 165 in base-10 representation.
Using other number bases other than base-10 is an equally valid way to represent the number 16510. Computers work well with binary numbers, so let's convert 165 to binary form:
16510 = 1 x 27 + 0 x 26 + 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22 +
0 x 21 + 1 x 20 = 101001012


Hexadecimal numbers are a base-16 representation of numbers and are useful for humans when dealing with binary numbers. Every 4 binary digits can be repesented by one hexadecimal digit. Below is a table of equivalence between decimal, hexadecimal, and binary number representations for the numbers between 0 and 15:

Credit to (Essentials of the MIDI protocol site)


number base equivalences
dec hex bin dec hex bin
=============== ===============
0 0 0 8 8 1000
1 1 1 9 9 1001
2 2 10 10 A 1010
3 3 11 11 B 1011
4 4 100 12 C 1100
5 5 101 13 D 1101
6 6 110 14 E 1110
7 7 111 15 F 1111




Using the above table, you should quickly be able to convert the number 101001012 to hexadecimal by grouping every four binary digits into a group and looking up the hex equivalent in the table.
101001012 ==> 1010 0101 ==> A 5 ==> A516


Since hexadecimal numbers contain digits for 10 through 15, it is standard practice to use the letters of the alphabet to reresent those digits, starting at A = 10.

In base-36, you would use all letters of the alphabet to represent all of the possible digits. Try to convert base-36 words to base-10, e.g.:
the36 = t x 362 + h x 361 + e x 360
= 29 x 362 + 17 x 361 + 14 x 360
= 37584 + 612 + 14
= 3821010


Hexadecimal numbers are often written with an h following them to distinguish them from decimal numbers, e.g.: A5h indicates that A5 is a hexadecimal number. There is no confustion in this case, but you would need to know if 42 is in base-10 or in base-16 since it is an entirely different number in each base and you can't tell which base it is by looking at it out of context.

In the C programming language, hexadecimal numbers are indicated by prepending the string "0x" in front of the number, e.g.: 0xA5 which would be the same as A5h. I will use the 0x notation later on this page.

Organization MIDI commands and data in a byte of information
MIDI bytes range between 0 and 255, or shown below in various representations:





Numeric range of MIDI bytes
decimal hexadecimal binary
=======================================================
0 0 0
255 FF 11111111




Note that a byte is a binary number that contains 8 digits. Looking at the binary range above you should be able to see that the range from 00000000 to 11111111 will cover all possible combinations of digits in a byte.

MIDI commands and data are distinguished according to the most significant bit of the byte. If there is a zero in the top bit, then the byte is a data byte, and if there is a one in the top bit, then the byte is a command byte. Here is how they are separated:






Division of data and commands by values
decimal hexadecimal binary
=======================================================
DATA bytes:
0 0 00000000
... ... ...
127 7F 01111111

COMMAND bytes:
128 80 10000000
... ... ...
255 FF 11111111




Furthermore, command bytes are split into half. The most significant half contains the actual MIDI command, and the second half contains the MIDI channel for which the command is for. For example, 0x91 is the note-on command for the second MIDI channel. the 9 digit is the actual command for note-on and the digit 1 specifies the second channel (the first channel being 0). The 0xF0 set of commands do not follow this convention.

Here is a table of the MIDI commands:






MIDI commands
0x80 Note Off
0x90 Note On
0xA0 Aftertouch
0xB0 Continuous controller
0xC0 Patch change
0xD0 Channel Pressure
0xE0 Pitch bend
0xF0 (non-musical commands)




The messages from 0x80 to 0xEF are called Channel Messages because the second four bits of the command specify which channel the message affects. The messages from 0xF0 to 0xFF are called System Messages; they do not affect any particular channel.

MIDI messages

A MIDI command plus its MIDI data parameters to be called a MIDI message . The minimum size of a MIDI message is 1 byte (one command byte and no parameter bytes). The maximum size of a MIDI message (note considering 0xF0 commands) is three bytes. A MIDI message always starts with a command byte. Here is a table of the MIDI messages that are possible in the MIDI protocol:





Command

Meaning

# parameters

param 1

param 2

0x80 Note-off 2 key velocity
0x90 Note-on 2 key veolcity
0xA0 Aftertouch 2 key touch
0xB0 Continuous controller 2 controller # controller value
0xC0 Patch change 2 instrument #
0xD0 Channel Pressure 1 pressure
0xE0 Pitch bend 2 lsb (7 bits) msb (7 bits)
0xF0 (non-musical commands)

I won't discuss the 0xF0 set of commands (System messages) here very much, but here is a basic table of them:





command

meaning

# param

0xF0 start of system exclusive message variable
0xF1 MIDI Time Code Quarter Frame (Sys Common)
0xF2 Song Position Pointer (Sys Common)
0xF3 Song Select (Sys Common)
0xF4 ???
0xF5 ???
0xF6 Tune Request (Sys Common)
0xF7 end of system exclusive message 0
0xF8 Timing Clock (Sys Realtime)
0xFA Start (Sys Realtime)
0xFB Continue (Sys Realtime)
0xFC Stop (Sys Realtime)
0xFD ???
0xFE Active Sensing (Sys Realtime)
0xFF System Reset (Sys Realtime)

Running status should be mentioned around here...
Report Abuse
mylifeis2cooldlol is not online. mylifeis2cooldlol
Joined: 08 Mar 2011
Total Posts: 874
20 Aug 2013 12:44 PM
Nice...now I have another thread to look at in my free time about music...




Not. Purpose of this was again?
Report Abuse
supremechloe is not online. supremechloe
Joined: 14 Apr 2012
Total Posts: 1624
20 Aug 2013 01:25 PM
)_) For expert Scripters...Who know how to MIDI
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
20 Aug 2013 01:34 PM
'For expert scripter who know how to MIDI'
Define the verb 'MIDI'

Report Abuse
supremechloe is not online. supremechloe
Joined: 14 Apr 2012
Total Posts: 1624
20 Aug 2013 01:50 PM
The SOunds you hear in games that sound like real music......go to Mario midis''''''' And listen to them
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:04 PM
"Computers work well with binary numbers, so let's convert 165 to binary form:
16510 = 1 x 27 + 0 x 26 + 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22 +
0 x 21 + 1 x 20 = 101001012"

Err...What?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:07 PM
165(base10) = 1*128 + 0*64 + 1*32 + 0*16 + 0*8 + 1*4 + 0*2 + 1*1 = 10100101(base2)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:07 PM
I see now. You lost your formatting.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:08 PM
Who wrote this, btw? You certainly didn't just type this up :/
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:10 PM
Never mind, found it: https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
20 Aug 2013 02:52 PM
That was a sarcastic question, supre.

This doesn't even have to do with Roblox MIDIs, this is actual .mid files
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Aug 2013 02:54 PM
Some guy made a script to convert the hex from .mid files into roblox midi stuff
Report Abuse
dog456pop248 is not online. dog456pop248
Joined: 24 Aug 2008
Total Posts: 3977
20 Aug 2013 02:56 PM
Yes, Gamehero.

However, this isn't related to that, this is related to actual .mid files on your computer
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image