home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 543a.lha / Nebula / source.LZH / source / grsound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-10  |  1.2 KB  |  76 lines

  1. /*
  2.  
  3. ------------------------------------------------------------------
  4.  
  5. Black Nebula
  6.  
  7. File :                Sound.c
  8. Programmer:        Colin Adams
  9. Date:                13/5/91
  10. Last Modified :    29/5/91
  11.  
  12. Description:
  13.  
  14. Plays sound files.  This file just calls routines in easysound.c
  15. which I did not write.
  16.  
  17. ------------------------------------------------------------------
  18.  
  19. */
  20.  
  21. #include <exec/types.h>
  22. #include "easysound.h"
  23.  
  24. char *samples[] =
  25. { "fire.snd",             // 0
  26.     "explosion.snd",    // 1
  27.     "missile1.snd",    // 2
  28. };
  29.  
  30. #define NUMBER_OF_SAMPLES (sizeof(samples)/sizeof(char *))
  31.  
  32. CPTR sounds[NUMBER_OF_SAMPLES];
  33.  
  34. void SoundSetUp(void)
  35. {
  36.     int i;
  37.     for(i=0; i<NUMBER_OF_SAMPLES; i++)
  38.     {
  39.         sounds[i] = PrepareSound(samples[i]);
  40.         if(!sounds[i])
  41.             printf("%d Error loading %s\n",i,samples[i]);
  42.     }
  43. }
  44.  
  45. void StartSound(int i)
  46. {
  47.     UBYTE channel;
  48.     
  49.     switch(i)
  50.     {
  51.         case 0: channel = LEFT0; break;
  52.         case 1: channel = RIGHT0; break;
  53.         case 2: channel = RIGHT1; break;
  54.         default:
  55.                 channel = LEFT1; break;
  56.     }
  57.     if(sounds[i])
  58.         PlaySound(sounds[i], MAXVOLUME, channel, NORMALRATE, 1);
  59. }
  60.  
  61. void EndSound(void)
  62. {
  63.     register int i;
  64.     
  65.     StopSound(LEFT0);
  66.     StopSound(RIGHT0);
  67.     StopSound(RIGHT1);
  68.     StopSound(LEFT1);
  69.     
  70.     for(i=0; i<NUMBER_OF_SAMPLES; i++)
  71.     {
  72.         RemoveSound(sounds[i]);
  73.         sounds[i] = 0;
  74.     }
  75. }
  76.