// // Programmer: Craig Stuart Sapp [craig@ccrma.stanford.edu] // Creation Date: Mon Dec 21 18:00:42 PST 1998 // Last Modified: Mon Dec 21 18:00:42 PST 1998 // Filename: ...linuxmidi/output/method1.c // Syntax: C // $Smake: gcc -O -o devmidiout devmidiout.c && strip devmidiout // #include #include #include #include #include #include extern int errno; int main(void) { char* device = "/dev/midi01" ; unsigned char data[3] = {0x90, 60, 127}; // step 1: open the OSS device for writing int fd = open(device, O_WRONLY, 0); if (fd < 0) { fprintf(stderr, "Error: cannot open %s: %s\n", device, strerror(errno)); exit(1); } // step 2: write the MIDI information to the OSS device write(fd, data, sizeof(data)); sleep(1); data[0] = 0x80; // turn the note off write(fd, data, sizeof(data)); // step 3: (optional) close the OSS device close(fd); return 0; }