home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: The Developer …nd Blaster Series Disk 1 / Lowe_TheDeveloperKitForSoundBlasterSeriesDisk1.img / C / MSC / MIDI / MIDIIN.C next >
Encoding:
C/C++ Source or Header  |  1991-10-25  |  3.3 KB  |  87 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*  @@ Source Documentation                           *** MSC Version ***   */
  3. /*                                                                          */
  4. /*  Copyright (c) Creative Technology Pte Ltd, 1991. All rights reserved.   */
  5. /*                                                                          */
  6. /*   TITLE       : MIDIIN.C                                                 */
  7. /*                                                                          */
  8. /*   DESCRIPTION :                                                          */
  9. /*       This program demostrates how to use the SBK MIDI interface         */
  10. /*       functions to read in the MIDI code through DSP and display         */
  11. /*       it on screen. The user can terminate the process by pressing       */
  12. /*       ESC key.                                                           */
  13. /*                                                                          */
  14. /*       The program checks BLASTER environment for the Card settings.      */
  15. /*       It also performs test base on BLASTER environment settings to      */
  16. /*       ensure they are tally with the hardware settings on the Card.      */
  17. /*                                                                          */
  18. /* ------------------------------------------------------------------------ */
  19.  
  20. #include  <stdio.h>
  21. #include  <bios.h>
  22. #include  <sbc.h>
  23. #include  <sbmidi.h>
  24.  
  25.  
  26. main()
  27. {
  28.     long lMidiCode, lTimeStamp;
  29.     unsigned char bMidiByte;
  30.  
  31.  
  32.     /* Retrieve the BLASTER environment settings */
  33.     if ( ! GetEnvSetting() )
  34.     {
  35.         if (sbc_check_card() & 4)
  36.         {
  37.             if (sbc_test_int())
  38.             {
  39.                 /* Start input */
  40.                 sbmidi_start_input();
  41.  
  42.                 while ( 1 )
  43.                 {
  44.                     /*  Check for ESC key  */
  45.                     if ( _bios_keybrd(_KEYBRD_READY) )
  46.                         if (_bios_keybrd(_KEYBRD_READ) == 0x11b)
  47.                             break;
  48.  
  49.                     /*  Read the MIDI input from buffer */
  50.                     if ( lMidiCode = sbmidi_get_input() )
  51.                     {
  52.  
  53.                         bMidiByte = (unsigned char)(lMidiCode & 0x000000ff);
  54.                         lTimeStamp = lMidiCode >> 8;
  55.  
  56.                         printf("\nMIDI Byte : %02x hex     ",bMidiByte);
  57.                         printf("Time Stamp : %8lu msec", lTimeStamp);
  58.                     }
  59.                 }
  60.  
  61.  
  62.                 /* Stop input */
  63.  
  64.                 sbmidi_stop_input();
  65.  
  66.  
  67.                 /* read the remaining codes in the buffer */
  68.  
  69.                 while ( lMidiCode = sbmidi_get_input() )
  70.                 {
  71.                     bMidiByte = (unsigned char)(lMidiCode & 0x000000ff);
  72.                     lTimeStamp = lMidiCode >> 8;
  73.  
  74.                     printf("\nMIDI Byte : %02x hex     ",bMidiByte);
  75.                     printf("Time Stamp : %8lu msec", lTimeStamp);
  76.                 }
  77.             }
  78.             else
  79.                 printf("Error on interrupt.\n");
  80.         }
  81.         else
  82.             printf("Sound Blaster Card not found or wrong I/O settings.\n") ;
  83.     }
  84.     else
  85.         printf("BLASTER environment not set or incomplete or invalid.\n");
  86. }
  87.