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

  1. /*********************************************************************
  2. *  octaplay                01 Aug 88         Copyright (c) 1988 cMIDI
  3. *
  4. *  cMIDI function library demonstration.  File 5 of 20.
  5. *
  6. *********************************************************************/
  7. #include <cmidi.h>
  8. #include <stdio.h>
  9.  
  10. main()
  11.    {
  12.    struct cm_message packet;
  13.  
  14.    /* Open cmidi and enable the queue for channel midi messages. */
  15.    CmidiOpen();
  16.    MpuSwitch( MPU_X_MIDI_THRU_OFF );
  17.    MpuSwitchCommand( MPU_X_CHANNEL_REF_TABLE_A_OFF );
  18.    MpuSwitchCommand( MPU_X_CHANNEL_REF_TABLE_B_OFF );
  19.    MpuSwitchCommand( MPU_X_CHANNEL_REF_TABLE_C_OFF );
  20.    MpuSwitchCommand( MPU_X_CHANNEL_REF_TABLE_D_OFF );
  21.    QueueMidiChan( ON );
  22.    if (ERRORQUEUED()) {CmidiClose(CLOSE_PRINT_ERRORS|CLOSE_RESET_MPU); exit();}
  23.  
  24.    printf("\nPlay the keyboard. Hit any key when finished.\n");
  25.  
  26.    /* Until any keys is hit */
  27.    while (!kbhit())
  28.       {
  29.       /* For each note received */
  30.       if (MIDICHANQUEUED())
  31.          {
  32.          TxMidiChan( packet=RxMidiChan() );
  33.          if (ISNOTEONOROFF(packet))
  34.             {
  35.             packet.data1 += 12;
  36.             TxMidiChan( packet );
  37.             }
  38.          }
  39.       }
  40.  
  41.    /* Close cmidi. */
  42.    CmidiClose( CLOSE_PRINT_ERRORS | CLOSE_RESET_MPU );
  43.    }
  44.