Re: [linux-audio-dev] Trying to get midi input using OSS

From: Jens M Andreasen <jens.andreasen@email-addr-hidden>
Date: Sun Feb 06 2005 - 08:31:45 EET

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
Received on Sun Feb 6 12:15:06 2005

This archive was generated by hypermail 2.1.8 : Sun Feb 06 2005 - 12:15:07 EET