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"
|
|
|
|
|
2007-03-10 04:21:32 +00:00
|
|
|
/**
|
|
|
|
\ingroup sound
|
|
|
|
*/
|
|
|
|
//@{
|
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;
|
2007-03-25 08:12:43 +00:00
|
|
|
sfx_t *owner;
|
2003-04-11 01:17:48 +00:00
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int length;
|
|
|
|
unsigned int loopstart;
|
2003-04-11 01:17:48 +00:00
|
|
|
|
2007-05-07 05:20:24 +00:00
|
|
|
union {
|
|
|
|
struct sfxstream_s *stream;
|
|
|
|
struct sfxblock_s *block;
|
|
|
|
} data;
|
2003-04-11 01:17:48 +00:00
|
|
|
|
|
|
|
struct sfxbuffer_s *(*touch) (sfx_t *sfx);
|
|
|
|
struct sfxbuffer_s *(*retain) (sfx_t *sfx);
|
2010-08-11 23:43:35 +00:00
|
|
|
void (*release) (sfx_t *sfx);
|
|
|
|
|
2007-03-18 10:32:01 +00:00
|
|
|
struct sfxbuffer_s *(*getbuffer) (sfx_t *sfx);
|
2003-04-11 21:14:38 +00:00
|
|
|
struct wavinfo_s *(*wavinfo) (sfx_t *sfx);
|
2010-08-11 23:43:35 +00:00
|
|
|
|
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
|
|
|
};
|
2007-03-10 04:21:32 +00:00
|
|
|
//@}
|
2001-04-09 21:15:09 +00:00
|
|
|
|
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 viewentity pointer to view entity index
|
|
|
|
\param host_frametime pointer to host frame time difference
|
|
|
|
*/
|
2012-02-13 04:44:29 +00:00
|
|
|
void S_Init (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.
|
|
|
|
*/
|
2007-03-17 03:10:45 +00:00
|
|
|
void S_StopAllSounds(void);
|
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
|
2012-02-13 04:44:29 +00:00
|
|
|
\param ambient_sound_level NUM_AMBIENTS bytes indicating current ambient
|
|
|
|
sound levels
|
2007-03-10 01:06:00 +00:00
|
|
|
*/
|
2002-01-03 05:29:38 +00:00
|
|
|
void S_Update (const vec3_t origin, const vec3_t v_forward,
|
2012-02-13 04:44:29 +00:00
|
|
|
const vec3_t v_right, const vec3_t v_up,
|
|
|
|
const byte *ambient_sound_level);
|
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
|
|
|
|
|
|
|
/** 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-18 12:54:59 +00:00
|
|
|
/** Stop and safely free a channel.
|
|
|
|
\param chan channel to stop
|
|
|
|
*/
|
|
|
|
void S_ChannelStop (struct channel_s *chan);
|
|
|
|
|
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-05-07 12:17:12 +00:00
|
|
|
/** Link sound engine builtins into the specified progs vm
|
|
|
|
\param pr the vm to link the builtins into.
|
|
|
|
*/
|
|
|
|
struct progs_s;
|
|
|
|
void S_Progs_Init (struct progs_s *pr);
|
|
|
|
|
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
|