home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / demos / midif / monitor.c < prev    next >
Text File  |  1988-09-03  |  1KB  |  53 lines

  1. /*********************************************************************
  2. *  monitor              01 Aug 88            Copyright (c) 1988 cMIDI
  3. *  cMIDI function library demonstration.  File 3 of 20.
  4. *
  5. *********************************************************************/
  6. #include <stdio.h>
  7. #include <cmidi.h>
  8. #define  RECEIVE_TIME_OUT     10
  9.  
  10. main()
  11.    {
  12.    unsigned char data;
  13.    int i, quit=0;
  14.  
  15.    /* Open cmidi and put mpu in uart mode. */
  16.    CmidiOpen();
  17.    if (ERRORQUEUED()) {CmidiClose( CLOSE_PRINT_ERRORS ); exit( 1 );}
  18.  
  19.    printf("\nPlay the keyboard. Pause for 10 seconds when finished\n\n"); 
  20.  
  21.    MpuSwitch( MPU_X_UART_MODE );
  22.  
  23.    /* Until time to quit */
  24.    while (!quit)
  25.       {
  26.       for (i=1; i<=16; i++)
  27.          {
  28.          /* Read data. */
  29.          data = MpuUartModeRx( RECEIVE_TIME_OUT );
  30.          MpuUartModeTx( data );
  31.  
  32.          /* If a run-time error has occurred */
  33.          if (ERRORQUEUED())
  34.             {
  35.             quit = 1;
  36.             break;
  37.             }
  38.          /* Print 16 bytes of data per line. */
  39.          printf( "%2.2X ",data );
  40.          if (i==8) printf("  ");
  41.          }
  42.       printf( "\n" );
  43.       }
  44.  
  45.    MpuReset();
  46.  
  47.    /* Close cmidi */
  48.    printf( "\n" );
  49.    CmidiClose( CLOSE_RESET_MPU );
  50.    }
  51.