[linux-audio-dev] Trying to get midi input using OSS
    Jens M Andreasen 
    jens.andreasen at chello.se
       
    Sun Feb  6 06:31:45 UTC 2005
    
    
  
Your program is testing for
  
   if (inpacket[0] == SEQ_MIDIPUTC)
.. which will never happen on the raw device.
Try this instead.
-------------------------------------------------------
#include <sys/soundcard.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#define  MIDI_DEVICE  "/dev/midi"
int main(void) {
   unsigned char input;
   // first open the midi device for reading.
   int seqfd = open(MIDI_DEVICE, O_RDONLY);
   if (seqfd == -1) {
      printf("Error: cannot open %s\n", MIDI_DEVICE);
      exit(1);
   } 
   // now just wait around for MIDI bytes to arrive
   while (1) {
      read(seqfd, &input,1);
 
      // print the MIDI byte
      if(input & 0x0080)
	printf("\nreceived MIDI status: %d\n",input );
      else
	printf("received MIDI data  : %d\n",input );
   }
      
   return 0;
}
-- 
   (
    )
  c[]  //  Jens M Andreasen
    
    
More information about the Linux-audio-dev
mailing list