/*
 * A test program for reading from /dev/midi.
 * Invoke it, and play something on the MIDI input keyboard.
 * Interrupt to terminate.
 */

#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/midi.h>

main(argc,argv)
int argc;
char **argv;
{
	int n, k;
	unsigned char buff[100];
	long t;
	int fd;

	if ( argc > 1 )
		fd = open(argv[1],O_RDONLY );
	else
		fd = open("/dev/midi",O_RDONLY );
	ioctl(fd,MIDIRESET,0);
	while ( 1 ) {
		if ( (n=read(fd,buff,sizeof(buff))) > 0 ) {
			ioctl(fd,MIDITIME,&t);
			printf("Time=%ld  ",t);
			for ( k=0; k<n; k++ )
				printf("  0x%x",buff[k]);
			printf("\n");
		}
	}
}


