The MIDI table.
midi.c
cc -std=c89 -Wall midi.c -o midi
Play note G
with velocity of 64
.
#include <linux/soundcard.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> int error(char* msg, const char* err) { printf("Error %s: %s\n", msg, err); return 0; } int main(void) { char* device = "/dev/midi2"; unsigned char g_on[3] = {0x90, 0x43, 0x40}; unsigned char g_off[3] = {0x80, 0x43, 0x00}; int f = open(device, O_WRONLY, 0); if(f < 0) return error("Unknown", device); printf("Note ON\n"); if(!write(f, g_on, sizeof(g_on))) return error("Note", "ON"); sleep(2); printf("Note OFF\n"); if(!write(f, g_off, sizeof(g_off))) return error("Note", "OFF"); close(f); return 0; }
Octave | HEX | DEC | Name | Frequency(Hz) |
---|---|---|---|---|
9 | 7f | 127 | G | 12,543.8539514160 |
7e | 126 | F#/Gb | 11,839.8215267723 | |
7d | 125 | F | 11,175.3034058561 | |
7c | 124 | E | 10,548.0818212118 | |
7b | 123 | D#/Eb | 9,956.0634791066 | |
7a | 122 | D | 9,397.2725733570 | |
79 | 121 | C#/Db | 8,869.8441912599 | |
78 | 120 | C | 8,372.0180896192 | |
8 | 77 | 119 | B | 7,902.1328200980 |
76 | 118 | A#/Bb | 7,458.6201842894 | |
75 | 117 | A | 7,040.0000000000 | |
74 | 116 | G#/Ab | 6,644.8751612791 | |
73 | 115 | G | 6,271.92697571 | |
72 | 114 | F#/Gb | 5,919.9107633862 | |
71 | 113 | F | 5,587.6517029281 | |
70 | 112 | E | 5,274.0409106059 | |
6f | 111 | D#/Eb | 4,978.0317395533 | |
6e | 110 | D | 4,698.6362866785 | |
6d | 109 | C#/Db | 4,434.9220956300 | |
6c | 108 | C | 4,186.0090448096 | |
7 | 6b | 107 | B | 3,951.0664100490 |
6a | 106 | A#/Bb | 3,729.3100921447 | |
69 | 105 | A | 3,520.0000000000 | |
68 | 104 | G#/Ab | 3,322.4375806396 | |
67 | 103 | G | 3,135.9634878540 | |
66 | 102 | F#/Gb | 2,959.9553816931 | |
65 | 101 | F | 2,793.8258514640 | |
64 | 100 | E | 2,637.0204553030 | |
63 | 99 | D#/Eb | 2,489.0158697766 | |
62 | 98 | D | 2,349.3181433393 | |
61 | 97 | C#/Db | 2,217.4610478150 | |
60 | 96 | C | 2,093.0045224048 | |
6 | 5f | 95 | B | 1,975.5332050245 |
5e | 94 | A#/Bb | 1,864.6550460724 | |
5d | 93 | A | 1,760.0000000000 | |
5c | 92 | G#/Ab | 1,661.2187903198 | |
5b | 91 | G | 1,567.9817439270 | |
5a | 90 | F#/Gb | 1,479.9776908465 | |
59 | 89 | F | 1,396.9129257320 | |
58 | 88 | E | 1,318.5102276515 | |
57 | 87 | D#/Eb | 1,244.5079348883 | |
56 | 86 | D | 1,174.6590716696 | |
55 | 85 | C#/Db | 1,108.7305239075 | |
54 | 84 | C | 1,046.5022612024 | |
5 | 53 | 83 | B | 987.7666025122 |
52 | 82 | A#/Bb | 932.3275230362 | |
51 | 81 | A | 880.0000000000 | |
50 | 80 | G#/Ab | 830.6093951599 | |
4f | 79 | G | 783.9908719635 | |
4e | 78 | F#/Gb | 739.9888454233< | |
4d | 77 | F | 698.4564628660< | |
4c | 76 | E | 659.2551138257< | |
4b | 75 | D#/Eb | 622.2539674442< | |
4a | 74 | D | 587.3295358348< | |
49 | 73 | C#/Db | 554.3652619537< | |
48 | 72 | C | 523.2511306012< | |
4 | 47 | 71 | B | 493.8833012561< |
46 | 70 | A#/Bb | 466.1637615181< | |
45 | 69 | A | 440.0000000000< | |
44 | 68 | G#/Ab | 415.3046975799< | |
43 | 67 | G | 391.9954359817< | |
42 | 66 | F#/Gb | 369.9944227116< | |
41 | 65 | F | 349.2282314330< | |
40 | 64 | E | 329.6275569129< | |
3f | 63 | D#/Eb | 311.1269837221< | |
3e | 62 | D | 293.6647679174< | |
3d | 61 | C#/Db | 277.1826309769< | |
3c | 60 | C | 261.6255653006< | |
3 | 3b | 59 | B | 246.9416506281 |
3a | 58 | A#/Bb | 233.0818807590 | |
39 | 57 | A | 220.0000000000 | |
38 | 56 | G#/Ab | 207.6523487900 | |
37 | 55 | G | 195.9977179909 | |
36 | 54 | F#/Gb | 184.9972113558 | |
35 | 53 | F | 174.6141157165 | |
34 | 52 | E | 164.8137784564 | |
33 | 51 | D#/Eb | 155.5634918610 | |
32 | 50 | D | 146.8323839587 | |
31 | 49 | C#/Db | 138.5913154884 | |
30 | 48 | C | 130.8127826503 | |
2 | 2f | 47 | B | 123.4708253140 |
2e | 46 | A#/Bb | 116.5409403795 | |
2d | 45 | A | 110.0000000000 | |
2c | 44 | G#/Ab | 103.8261743950 | |
2b | 43 | G | 97.9988589954 | |
2a | 42 | F#/Gb | 92.4986056779 | |
29 | 41 | F | 87.3070578583 | |
28 | 40 | E | 82.4068892282 | |
27 | 39 | D#/Eb | 77.7817459305 | |
26 | 38 | D | 73.4161919794 | |
25 | 37 | C#/Db | 69.2956577442 | |
24 | 36 | C | 65.4063913251 | |
1 | 23 | 35 | B | 61.7354126570 |
22 | 34 | A#/Bb | 58.2704701898 | |
21 | 33 | A | 55.0000000000 | |
20 | 32 | G#/Ab | 51.9130871975 | |
1f | 31 | G | 48.9994294977 | |
1e | 30 | F#/Gb | 46.2493028390 | |
1d | 29 | F | 43.6535289291 | |
1c | 28 | E | 41.2034446141 | |
1b | 27 | D#/Eb | 38.8908729653 | |
1a | 26 | D | 36.7080959897 | |
19 | 25 | C#/Db | 34.6478288721 | |
18 | 24 | C | 32.7031956626 | |
0 | 17 | 23 | B | 30.8677063285 |
16 | 22 | A#/Bb | 29.1352350949 | |
15 | 21 | A | 27.5000000000 | |
14 | 20 | G#/Ab | 25.9565435987 | |
13 | 19 | G | 24.4997147489 | |
12 | 18 | F#/Gb | 23.1246514195 | |
11 | 17 | F | 21.8267644646 | |
10 | 16 | E | 20.6017223071 | |
0f | 15 | D#/Eb | 19.4454364826 | |
0e | 14 | D | 18.3540479948 | |
0d | 13 | C#/Db | 17.3239144361 | |
0c | 12 | C | 16.3515978313 | |
-1 | 0b | 11 | B | 15.4338531643 |
0a | 10 | A#/Bb | 14.5676175474 | |
09 | 9 | A | 13.7500000000 | |
08 | 8 | G#/Ab | 12.9782717994 | |
07 | 7 | G | 12.2498573744 | |
06 | 6 | F#/Gb | 11.5623257097 | |
05 | 5 | F | 10.9133822323 | |
04 | 4 | E | 10.3008611535 | |
03 | 3 | D#/Eb | 9.7227182413 | |
02 | 2 | D | 9.1770239974 | |
01 | 1 | C#/Db | 8.6619572180 | |
00 | 0 | C | 8.1757989156 |
Octave / Note | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|---|---|---|---|---|---|---|---|---|
C | 16 | 33 | 65 | 131 | 262 | 523 | 1047 | 2093 | 4186 |
C♯ | 17 | 35 | 69 | 139 | 277 | 554 | 1109 | 2217 | 4435 |
D | 18 | 37 | 73 | 147 | 294 | 587 | 1175 | 2349 | 4699 |
D♯ | 19 | 39 | 78 | 156 | 311 | 622 | 1245 | 2489 | 4978 |
E | 21 | 41 | 82 | 165 | 330 | 659 | 1319 | 2637 | 5274 |
F | 22 | 44 | 87 | 175 | 349 | 698 | 1397 | 2794 | 5588 |
F♯ | 23 | 46 | 93 | 185 | 370 | 740 | 1480 | 2960 | 5920 |
G | 25 | 49 | 98 | 196 | 392 | 784 | 1568 | 3136 | 6272 |
G♯ | 26 | 52 | 104 | 208 | 415 | 831 | 1661 | 3322 | 6645 |
A | 28 | 55 | 110 | 220 | 440 | 880 | 1760 | 3520 | 7040 |
A♯ | 29 | 58 | 117 | 233 | 466 | 932 | 1865 | 3729 | 7459 |
B | 31 | 62 | 123 | 247 | 494 | 988 | 1976 | 3951 | 7902 |
MIDI could only describe the tile mosaic world of the keyboardist, not the watercolor world of the violin.
incoming hexadecimal