ich möchte in linux ein c programm schreiben, dass mir midi "töne" ausgibt.
ich habe folgenden quellcode, der ohne errors oder warnings compiliert. aber ich höre keinen sound. ich glaube, dass es nicht an dem source file liegt, sondern an irgendetwas system technischen, denn ich kann midi files nur mittels kmidi abspielen, und da rauscht es ziemlich. weiss jemand rat?
Code:
#include <linux/soundcard.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(void) {
char* device = "/dev/midi" ;
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) {
printf("Error: cannot open %s\n", device);
exit(1);
}
// step 2: write the MIDI information to the OSS device
write(fd, data, sizeof(data));
// step 3: (optional) close the OSS device
close(fd);
return 0;
}
Lesezeichen