2
* Purpose: A minimalistic MIDI input programming sample.
3
* Copyright (C) 4Front Technologies, 2002-2004. Released under GPLv2/CDDL.
6
* This simple program opens a MIDI device file and displays everything
7
* it receives in hexadecimal format.
9
* Please look at the "{!link MIDI}" section of the OSS Developer's
10
* manual for more info about MIDI programming.
17
#include <soundcard.h>
19
#define DEVICE "/dev/midi"
25
unsigned char buf[128];
28
if ((fd = open (DEVICE, O_RDONLY, 0)) == -1)
30
perror ("open " DEVICE);
35
* Note that read may return any number of bytes between 0 and sizeof(buf).
36
* -1 means that some error has occurred.
39
while ((l = read (fd, buf, sizeof (buf))) != -1)
43
for (i = 0; i < l; i++)
45
if (buf[i] & 0x80) /* Status byte */
47
printf ("%02x ", buf[i]);