sound_local.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Copyright (C) 2004-2005 Michael Liebscher
  3. Copyright (C) 1997-2001 Id Software, Inc.
  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. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. /*
  17. * sound_local.h:
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. * Date: 2004
  21. *
  22. * Acknowledgement:
  23. * This code was derived from Quake II, and was originally
  24. * written by Id Software, Inc.
  25. *
  26. * Acknowledgement:
  27. * Portion of this code was derived from Quake II Evolved.
  28. *
  29. */
  30. #ifndef __SOUND_LOCAL_H__
  31. #define __SOUND_LOCAL_H__
  32. typedef struct sfx_s
  33. {
  34. char name[ MAX_GAMEPATH ];
  35. _boolean defaulted;
  36. _boolean loaded;
  37. int samples;
  38. int rate;
  39. unsigned format; /* Sound samples: format specifier */
  40. unsigned bufferNum;
  41. struct sfx_s *nextHash;
  42. } sfx_t;
  43. // A playSound will be generated by each call to S_StartSound.
  44. // When the mixer reaches playSound->beginTime, the playSound will be
  45. // assigned to a channel.
  46. typedef struct playSound_s
  47. {
  48. struct playSound_s *prev, *next;
  49. sfx_t *sfx;
  50. int entNum;
  51. int entChannel;
  52. _boolean fixedPosition; // Use position instead of fetching entity's origin
  53. vec3_t position; // Only use if fixedPosition is set
  54. float volume;
  55. float attenuation;
  56. int beginTime; // Begin at this time
  57. } playSound_t;
  58. typedef struct
  59. {
  60. _boolean streaming;
  61. sfx_t *sfx; // NULL if unused
  62. int entNum; // To allow overriding a specific sound
  63. int entChannel;
  64. int startTime; // For overriding oldest sounds
  65. _boolean loopSound; // Looping sound
  66. int loopNum; // Looping entity number
  67. int loopFrame; // For stopping looping sounds
  68. _boolean fixedPosition; // Use position instead of fetching entity's origin
  69. vec3_t position; // Only use if fixedPosition is set
  70. float volume;
  71. float distanceMult;
  72. unsigned sourceName; // OpenAL sourceName
  73. } channel_t;
  74. typedef struct
  75. {
  76. vec3_t position;
  77. vec3_t velocity;
  78. float orientation[ 6 ];
  79. } listener_t;
  80. // extern void Sound_SoundList_f( void );
  81. extern _boolean Sound_LoadSound( sfx_t *sfx );
  82. extern sfx_t *Sound_FindSound( const char *name );
  83. extern void Sound_FreeSounds( void );
  84. extern _boolean Sound_Device_Setup( void );
  85. extern void Sound_Device_Shutdown( void );
  86. #endif /* __SOUND_LOCAL_H__ */