home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quakeworld_src / client / sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-17  |  4.8 KB  |  175 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // sound.h -- client sound i/o functions
  21.  
  22. #ifndef __SOUND__
  23. #define __SOUND__
  24.  
  25. // !!! if this is changed, it much be changed in asm_i386.h too !!!
  26. typedef struct
  27. {
  28.   int left;
  29.   int right;
  30. } portable_samplepair_t;
  31.  
  32. typedef struct sfx_s
  33. {
  34.   char  name[MAX_QPATH];
  35.   cache_user_t  cache;
  36. } sfx_t;
  37.  
  38. // !!! if this is changed, it much be changed in asm_i386.h too !!!
  39. typedef struct
  40. {
  41.   int   length;
  42.   int   loopstart;
  43.   int   speed;
  44.   int   width;
  45.   int   stereo;
  46.   byte  data[1];    // variable sized
  47. } sfxcache_t;
  48.  
  49. typedef struct
  50. {
  51.   qboolean    gamealive;
  52.   qboolean    soundalive;
  53.   qboolean    splitbuffer;
  54.   int       channels;
  55.   int       samples;        // mono samples in buffer
  56.   int       submission_chunk;   // don't mix less than this #
  57.   int       samplepos;        // in mono samples
  58.   int       samplebits;
  59.   int       speed;
  60.   unsigned char *buffer;
  61. } dma_t;
  62.  
  63. // !!! if this is changed, it much be changed in asm_i386.h too !!!
  64. typedef struct
  65. {
  66.   sfx_t *sfx;     // sfx number
  67.   int   leftvol;    // 0-255 volume
  68.   int   rightvol;   // 0-255 volume
  69.   int   end;      // end time in global paintsamples
  70.   int   pos;      // sample position in sfx
  71.   int   looping;    // where to loop, -1 = no looping
  72.   int   entnum;     // to allow overriding a specific sound
  73.   int   entchannel;   //
  74.   vec3_t  origin;     // origin of sound effect
  75.   vec_t dist_mult;    // distance multiplier (attenuation/clipK)
  76.   int   master_vol;   // 0-255 master volume
  77. } channel_t;
  78.  
  79. typedef struct
  80. {
  81.   int   rate;
  82.   int   width;
  83.   int   channels;
  84.   int   loopstart;
  85.   int   samples;
  86.   int   dataofs;    // chunk starts this many bytes from file start
  87. } wavinfo_t;
  88.  
  89. void S_Init (void);
  90. void S_Startup (void);
  91. void S_Shutdown (void);
  92. void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol,  float attenuation);
  93. void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
  94. void S_StopSound (int entnum, int entchannel);
  95. void S_StopAllSounds(qboolean clear);
  96. void S_ClearBuffer (void);
  97. void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
  98. void S_ExtraUpdate (void);
  99.  
  100. sfx_t *S_PrecacheSound (char *sample);
  101. void S_TouchSound (char *sample);
  102. void S_ClearPrecache (void);
  103. void S_BeginPrecaching (void);
  104. void S_EndPrecaching (void);
  105. void S_PaintChannels(int endtime);
  106. void S_InitPaintChannels (void);
  107.  
  108. // picks a channel based on priorities, empty slots, number of channels
  109. channel_t *SND_PickChannel(int entnum, int entchannel);
  110.  
  111. // spatializes a channel
  112. void SND_Spatialize(channel_t *ch);
  113.  
  114. // initializes cycling through a DMA buffer and returns information on it
  115. qboolean SNDDMA_Init(void);
  116.  
  117. // gets the current DMA position
  118. int SNDDMA_GetDMAPos(void);
  119.  
  120. // shutdown the DMA xfer.
  121. void SNDDMA_Shutdown(void);
  122.  
  123. // ====================================================================
  124. // User-setable variables
  125. // ====================================================================
  126.  
  127. #define MAX_CHANNELS      128
  128. #define MAX_DYNAMIC_CHANNELS  8
  129.  
  130.  
  131. extern  channel_t   channels[MAX_CHANNELS];
  132. // 0 to MAX_DYNAMIC_CHANNELS-1  = normal entity sounds
  133. // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc
  134. // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds
  135.  
  136. extern  int     total_channels;
  137.  
  138. //
  139. // Fake dma is a synchronous faking of the DMA progress used for
  140. // isolating performance in the renderer.  The fakedma_updates is
  141. // number of times S_Update() is called per second.
  142. //
  143.  
  144. extern qboolean     fakedma;
  145. extern int      fakedma_updates;
  146. extern int    paintedtime;
  147. extern vec3_t listener_origin;
  148. extern vec3_t listener_forward;
  149. extern vec3_t listener_right;
  150. extern vec3_t listener_up;
  151. extern volatile dma_t *shm;
  152. extern volatile dma_t sn;
  153. extern vec_t sound_nominal_clip_dist;
  154.  
  155. extern  cvar_t loadas8bit;
  156. extern  cvar_t bgmvolume;
  157. extern  cvar_t volume;
  158.  
  159. extern qboolean snd_initialized;
  160.  
  161. extern int    snd_blocked;
  162.  
  163. void S_LocalSound (char *s);
  164. sfxcache_t *S_LoadSound (sfx_t *s);
  165.  
  166. wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength);
  167.  
  168. void SND_InitScaletable (void);
  169. void SNDDMA_Submit(void);
  170.  
  171. void S_AmbientOff (void);
  172. void S_AmbientOn (void);
  173.  
  174. #endif
  175.