Use the Midi interface to create a simulated piano

Source: Internet
Author: User

Since it is computer music, some computer knowledge is essential. programmers who are familiar with binary can skip this part.

Common hexadecimal and decimal table

It is not just to remember this, but to be familiar with these commonly used numbers. When looking at other people's programs, don't know what these numbers do.

A MIDI file contains commands composed of many pieces of information. Some information consists of only one byte, some have two bytes, some are composed of three bytes, and many are composed.

All information is the same, that is, the first byte of information is the state. The 0x80 to 0xef values of Status bytes are any information that can appear in 16 MIDI channels. Because of this, these are so-called sound information. These Status bytes have 8-bit binary numbers. You can divide 8 binary bytes into two
Four digits, that is, a high position and a low position. For example, 0x92 of a status byte can be subdivided into 9 (high) and 2 (low ). The High Level tells you what type of MIDI information, and the low level describes the Midi channel number of the information operation. Below are all possible high-level values, each representing the type of sound information: The following explains the above terminology (refer to Baidu encyclopedia) to stop the sound category: Sound
Purpose
Indicates the audio to be stopped.
0x80 to 0x8f while the low position is the Midi channel.
Data
The next two data bytes.
The first data is the note number. There are 128 notes, for MIDI devices, numbered 0 to 127 (where, the central C is numbered 60 ).
The second Data byte is the speed, a value from 0 to 127. This shows how quickly the voice should be stopped (127 of which are the fastest ).

Start to speak
Category: Sound
Purpose
Specifies the voice to be sent.
Status byte
0x90 to 0x9f while the low position is the Midi channel.
Data
Next two data bytes
Note:
In theory, each note should end with its own stop voice information.

Wheel finger
Category: Sound
Purpose
Continuously replays the sound that has been made.
Status byte
0xa0 to 0xaf, while the low position is the Midi channel.
Data
The next two data bytes.
The first data is the symbol code. There are 128 possible notes. For MIDI devices, numbers are 0 to 127 (the central C note code is 60 ).
The second Data byte is the volume value, from 0 to 127 (where 127 is a strong tone ).
Note:

Controller change
Category: Sound
Purpose
Set the value of a specific controller. Status byte
0xb0, to 0xbf, and low is the Midi channel.
Data
The next two data bytes.
The first data is the Controller number (0 to 127 ).
The value of the second Data byte is the value set by the Controller, from 0 to 127.

Change tone
Category: Sound
Status byte
0xc0, to 0xcf, and low is the Midi channel.
Data
One Data byte. This is the number of the instrument, from 0 to 127.
Note:
A set of standards are defined for MIDI tones for better compatibility. This standard is a general MIDI standard.

Channel playing pressure
Category: Sound
Status byte
0xd0 to 0xdf while the low position is the Midi channel.
Data
A Data byte with a value ranging from 0 to 127 (127 of which is the loudest ).

Pitch
Category: Sound
Status byte
0xe0 to 0xef while the low position is the Midi channel.
Data
The next two data bytes. These two bytes should be combined to form a 14-bit value.

Dedicated system information
Category: System Public
Purpose
It is used to transmit some data, which is specific to a MIDI device. In addition, sysex may be used to transmit information, which is a specific device.
Status byte
Starting from 0xf0. End at 0xf7.
Data
There can be any number of data bytes. After knowing how to control the MIDI device, you still need some tables to support these commands. 1. Tone table: http://blog.csdn.net/jia_zhengshen/article/details/8777194 tone table mainly introduces the code of the instrument. Such as piano, guitar, gunshots, etc. 2 Controller table: http://blog.csdn.net/jia_zhengshen/article/details/8777836 this is mainly used to adjust the volume, adjust the balance control and so on. It is useful in adjusting the beauty of music. 3. MIDI note code table: http://blog.csdn.net/jia_zhengshen/article/details/8778457 can be sure to play the piano or guitar, you can adjust the volume, what is the difference? Your piano won't be just a key! By the way, this table selects the note you press. Of course, if you want to know which key you press, You have to refer to the distribution of the key. The link is http://blog.csdn.net/jia_zhengshen/article/details/8778637. Now, if you have read my blog, you can create a piano simulation on your computer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.