XXIIVV

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;
}

OctaveHEXDECNameFrequency(Hz)
97f127G12,543.8539514160
7e126F#/Gb11,839.8215267723
7d125F11,175.3034058561
7c124E10,548.0818212118
7b123D#/Eb9,956.0634791066
7a122D9,397.2725733570
79121C#/Db8,869.8441912599
78120C8,372.0180896192
877119B7,902.1328200980
76118A#/Bb7,458.6201842894
75117A7,040.0000000000
74116G#/Ab6,644.8751612791
73115G6,271.92697571
72114F#/Gb5,919.9107633862
71113F5,587.6517029281
70112E5,274.0409106059
6f111D#/Eb4,978.0317395533
6e110D4,698.6362866785
6d109C#/Db4,434.9220956300
6c108C4,186.0090448096
76b107B3,951.0664100490
6a106A#/Bb3,729.3100921447
69105A3,520.0000000000
68104G#/Ab3,322.4375806396
67103G3,135.9634878540
66102F#/Gb2,959.9553816931
65101F2,793.8258514640
64100E2,637.0204553030
6399D#/Eb2,489.0158697766
6298D2,349.3181433393
6197C#/Db2,217.4610478150
6096C2,093.0045224048
65f95B1,975.5332050245
5e94A#/Bb1,864.6550460724
5d93A1,760.0000000000
5c92G#/Ab1,661.2187903198
5b91G1,567.9817439270
5a90F#/Gb1,479.9776908465
5989F1,396.9129257320
5888E1,318.5102276515
5787D#/Eb1,244.5079348883
5686D1,174.6590716696
5585C#/Db1,108.7305239075
5484C1,046.5022612024
55383B987.7666025122
5282A#/Bb932.3275230362
5181A880.0000000000
5080G#/Ab830.6093951599
4f79G783.9908719635
4e78F#/Gb739.9888454233<
4d77F698.4564628660<
4c76E659.2551138257<
4b75D#/Eb622.2539674442<
4a74D587.3295358348<
4973C#/Db554.3652619537<
4872C523.2511306012<
44771B493.8833012561<
4670A#/Bb466.1637615181<
4569A440.0000000000<
4468G#/Ab415.3046975799<
4367G391.9954359817<
4266F#/Gb369.9944227116<
4165F349.2282314330<
4064E329.6275569129<
3f63D#/Eb311.1269837221<
3e62D293.6647679174<
3d61C#/Db277.1826309769<
3c60C261.6255653006<
33b59B246.9416506281
3a58A#/Bb233.0818807590
3957A220.0000000000
3856G#/Ab207.6523487900
3755G195.9977179909
3654F#/Gb184.9972113558
3553F174.6141157165
3452E164.8137784564
3351D#/Eb155.5634918610
3250D146.8323839587
3149C#/Db138.5913154884
3048C130.8127826503
22f47B123.4708253140
2e46A#/Bb116.5409403795
2d45A110.0000000000
2c44G#/Ab103.8261743950
2b43G97.9988589954
2a42F#/Gb92.4986056779
2941F87.3070578583
2840E82.4068892282
2739D#/Eb77.7817459305
2638D73.4161919794
2537C#/Db69.2956577442
2436C65.4063913251
12335B61.7354126570
2234A#/Bb58.2704701898
2133A55.0000000000
2032G#/Ab51.9130871975
1f31G48.9994294977
1e30F#/Gb46.2493028390
1d29F43.6535289291
1c28E41.2034446141
1b27D#/Eb38.8908729653
1a26D36.7080959897
1925C#/Db34.6478288721
1824C32.7031956626
01723B30.8677063285
1622A#/Bb29.1352350949
1521A27.5000000000
1420G#/Ab25.9565435987
1319G24.4997147489
1218F#/Gb23.1246514195
1117F21.8267644646
1016E20.6017223071
0f15D#/Eb19.4454364826
0e14D18.3540479948
0d13C#/Db17.3239144361
0c12C16.3515978313
-10b11B15.4338531643
0a10A#/Bb14.5676175474
099A13.7500000000
088G#/Ab12.9782717994
077G12.2498573744
066F#/Gb11.5623257097
055F10.9133822323
044E10.3008611535
033D#/Eb9.7227182413
022D9.1770239974
011C#/Db8.6619572180
000C8.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