2001-04-09 21:15:09 +00:00
|
|
|
/*
|
|
|
|
sound.h
|
|
|
|
|
2001-04-10 20:15:18 +00:00
|
|
|
Sound headers.
|
2001-04-09 21:15:09 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
// sound.h -- client sound i/o functions
|
|
|
|
|
|
|
|
#ifndef _SOUND_H
|
|
|
|
#define _SOUND_H
|
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** \defgroup sound QuakeForge sound engine
|
|
|
|
*/
|
|
|
|
|
2001-04-09 21:15:09 +00:00
|
|
|
#include "QF/mathlib.h"
|
|
|
|
|
2001-04-10 09:40:09 +00:00
|
|
|
#define AMBIENT_WATER 0
|
2003-04-11 01:17:48 +00:00
|
|
|
#define AMBIENT_SKY 1
|
2001-04-10 09:40:09 +00:00
|
|
|
#define AMBIENT_SLIME 2
|
|
|
|
#define AMBIENT_LAVA 3
|
|
|
|
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
|
|
|
|
2001-04-10 20:15:18 +00:00
|
|
|
#define DEFAULT_SOUND_PACKET_VOLUME 255
|
|
|
|
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
|
|
|
|
|
2003-04-11 01:17:48 +00:00
|
|
|
typedef struct sfx_s sfx_t;
|
|
|
|
struct sfx_s
|
2001-04-09 21:15:09 +00:00
|
|
|
{
|
2003-04-11 01:17:48 +00:00
|
|
|
const char *name;
|
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int length;
|
|
|
|
unsigned int loopstart;
|
2003-04-11 01:17:48 +00:00
|
|
|
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
struct sfxbuffer_s *(*touch) (sfx_t *sfx);
|
|
|
|
struct sfxbuffer_s *(*retain) (sfx_t *sfx);
|
2003-04-11 21:14:38 +00:00
|
|
|
struct wavinfo_s *(*wavinfo) (sfx_t *sfx);
|
2003-04-20 07:19:51 +00:00
|
|
|
sfx_t *(*open) (sfx_t *sfx);
|
|
|
|
void (*close) (sfx_t *sfx);
|
2003-04-11 01:17:48 +00:00
|
|
|
void (*release) (sfx_t *sfx);
|
|
|
|
};
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2004-01-08 03:46:11 +00:00
|
|
|
typedef struct dma_s {
|
2001-04-09 21:15:09 +00:00
|
|
|
qboolean gamealive;
|
|
|
|
qboolean soundalive;
|
|
|
|
qboolean splitbuffer;
|
|
|
|
int channels;
|
|
|
|
int samples; // mono samples in buffer
|
|
|
|
int submission_chunk; // don't mix less than this #
|
|
|
|
int samplepos; // in mono samples
|
|
|
|
int samplebits;
|
|
|
|
int speed;
|
|
|
|
unsigned char *buffer;
|
|
|
|
} dma_t;
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
struct model_s;
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** \defgroup sound_init Initialization functions
|
|
|
|
\ingroup sound
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/** Initialize the sound engine.
|
|
|
|
\param worldmodel pointer to the main engine's world model pointer
|
|
|
|
\param viewentity pointer to view entity index
|
|
|
|
\param host_frametime pointer to host frame time difference
|
|
|
|
*/
|
2001-10-28 04:23:37 +00:00
|
|
|
void S_Init (struct model_s **worldmodel, int *viewentity,
|
|
|
|
double *host_frametime);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Initialize the Cvars for the sound engine. Call before calling S_Init().
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_Init_Cvars (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Shutdown the sound engine. Allows audio output modules to shutdown
|
|
|
|
gracefully.
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_Shutdown (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/** \defgroup sound_stuff Unclassified
|
|
|
|
\ingroup sound
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/** Start a sound playing.
|
|
|
|
\param entnum index of entity the sound is associated with.
|
|
|
|
\param entchannel 0-7
|
|
|
|
- 0 auto (never willingly overrides)
|
|
|
|
- 1 weapon
|
|
|
|
- 2 voice
|
|
|
|
- 3 item
|
|
|
|
- 4 body
|
|
|
|
\param sfx sound to play
|
|
|
|
\param origin 3d coords of where the sound originates
|
|
|
|
\param fvol absolute volume of the sound
|
|
|
|
\param attenuation rate of volume dropoff vs distance
|
|
|
|
*/
|
2002-01-03 05:29:38 +00:00
|
|
|
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, const vec3_t origin,
|
|
|
|
float fvol, float attenuation);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Create a sound generated by the world.
|
|
|
|
\param sfx sound to play
|
|
|
|
\param origin 3d coords of where the sound originates
|
|
|
|
\param vol absolute volume of the sound
|
|
|
|
\param attenuation rate of volume dropoff vs distance
|
|
|
|
*/
|
2002-01-03 05:29:38 +00:00
|
|
|
void S_StaticSound (sfx_t *sfx, const vec3_t origin, float vol,
|
|
|
|
float attenuation);
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Stop an entity's sound.
|
|
|
|
\param entnum index of entity the sound is associated with.
|
|
|
|
\param entchannel channel to silence
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_StopSound (int entnum, int entchannel);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Stop all sounds from playing.
|
|
|
|
\param clear if true, the buffer is cleared so sound stops immediately
|
|
|
|
rather than trailing off
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_StopAllSounds(qboolean clear);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Update the sound engine with the client's position and orientation and
|
|
|
|
render some sound.
|
|
|
|
\param origin 3d coords of the client
|
|
|
|
\param v_forward 3d vector of the client's facing direction
|
|
|
|
\param v_right 3d vector of the client's rightward direction
|
|
|
|
\param v_up 3d vector of the client's upward direction
|
|
|
|
*/
|
2002-01-03 05:29:38 +00:00
|
|
|
void S_Update (const vec3_t origin, const vec3_t v_forward,
|
|
|
|
const vec3_t v_right, const vec3_t v_up);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Render some more sound without updating the client's position/orientation.
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_ExtraUpdate (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Pause the sound output. Nested blocking is supported, so calls to
|
|
|
|
S_BlockSound() and S_UnblockSound() must be balanced.
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_BlockSound (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Unpause the sound output. Nested blocking is supported, so calls to
|
|
|
|
S_BlockSound() and S_UnblockSound() must be balanced.
|
|
|
|
*/
|
2001-07-05 20:18:23 +00:00
|
|
|
void S_UnblockSound (void);
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Pre-load a sound into the cache.
|
|
|
|
\param sample name of sound to precache
|
|
|
|
*/
|
2001-07-15 07:04:17 +00:00
|
|
|
sfx_t *S_PrecacheSound (const char *sample);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Tag a cached sound to prevent it being flushed unnecessarily.
|
|
|
|
\param sample name of sound touch
|
|
|
|
\todo check that Cache_TryGet() does the right thing
|
|
|
|
*/
|
2001-07-15 07:04:17 +00:00
|
|
|
void S_TouchSound (const char *sample);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Does nothing.
|
|
|
|
\todo remove?
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_ClearPrecache (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Does nothing.
|
|
|
|
\todo remove?
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_BeginPrecaching (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Does nothing.
|
|
|
|
\todo remove?
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_EndPrecaching (void);
|
2003-01-31 20:51:04 +00:00
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Pre-load a sound.
|
|
|
|
\param name name of sound to load
|
|
|
|
*/
|
2004-01-21 02:52:12 +00:00
|
|
|
sfx_t *S_LoadSound (const char *name);
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Allocate a sound channel that can be used for playing sounds.
|
|
|
|
*/
|
|
|
|
struct channel_s *S_AllocChannel (void);
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Start a sound local to the client view.
|
|
|
|
\param s name of sound to play
|
|
|
|
*/
|
2001-07-15 07:04:17 +00:00
|
|
|
void S_LocalSound (const char *s);
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
/** Disable ambient sounds.
|
|
|
|
\todo not used, remove?
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_AmbientOff (void);
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** Enable ambient sounds.
|
|
|
|
\todo not used, remove?
|
|
|
|
*/
|
2001-04-09 21:15:09 +00:00
|
|
|
void S_AmbientOn (void);
|
|
|
|
|
2007-03-10 01:06:00 +00:00
|
|
|
//@}
|
2001-10-28 04:23:37 +00:00
|
|
|
|
2001-04-09 21:15:09 +00:00
|
|
|
#endif // _SOUND_H
|