/********************************************************************
* 
*  lefty                01 Aug 88            Copyright (c) cMIDI 1988  
* 
*  cMIDI function library demonstration.  File 4 of 20.
*
*********************************************************************/
#include <cmidi.h>
#include <stdio.h>

main()
   {
   struct cm_message packet;

   /* Open cmidi and enable the queue for channel midi messages. */
   CmidiOpen();
   MpuSwitch( MPU_X_MIDI_THRU_OFF );
   QueueMidiChan( ON );
   if (ERRORQUEUED()) { CmidiClose( CLOSE_PRINT_ERRORS ); exit( 1 );}

   printf("\nPlay the keyboard. Hit any key when finished.\n");

   /* Until any keyboard character is entered */
   while ( !kbhit() )
      {
      if (MIDICHANQUEUED())
         {
         packet = RxMidiChan();
         if (ISNOTEONOROFF(packet))
            packet.data1 = 124 - packet.data1;
         TxMidiChan( packet );
         }
      }
   
   /* Close cmidi. */
   CmidiClose( CLOSE_RESET_MPU );
   }
