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
|
|
|
|
|
|
|
|
*/
|
|
|
|
// sound.h -- client sound i/o functions
|
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#ifndef __QF_sound_h
|
|
|
|
#define __QF_sound_h
|
2001-04-09 21:15:09 +00:00
|
|
|
|
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"
|
2022-03-30 14:38:01 +00:00
|
|
|
#include "QF/simd/types.h"
|
2001-04-09 21:15:09 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
struct transform_s;
|
|
|
|
|
2007-03-10 04:21:32 +00:00
|
|
|
/**
|
|
|
|
\ingroup sound
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
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
|
|
|
{
|
2021-06-23 15:04:02 +00:00
|
|
|
struct snd_s *snd; //!< ownding snd_t instance
|
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
|
|
|
};
|
2020-02-11 06:20:49 +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
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** 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);
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** \defgroup sound_stuff Unclassified
|
|
|
|
\ingroup sound
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2007-03-10 01:06:00 +00:00
|
|
|
|
|
|
|
/** 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
|
2021-06-25 07:52:09 +00:00
|
|
|
\param vol absolute volume of the sound
|
2007-03-10 01:06:00 +00:00
|
|
|
\param attenuation rate of volume dropoff vs distance
|
|
|
|
*/
|
2022-03-30 14:38:01 +00:00
|
|
|
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec4f_t origin,
|
2021-06-25 07:52:09 +00:00
|
|
|
float vol, 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
|
|
|
|
*/
|
2022-03-30 14:38:01 +00:00
|
|
|
void S_StaticSound (sfx_t *sfx, vec4f_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.
|
2022-02-28 07:59:38 +00:00
|
|
|
\param ear Transform for the position and orientation of the stereo
|
|
|
|
sound pickup.
|
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
|
|
|
*/
|
2022-02-28 07:59:38 +00:00
|
|
|
void S_Update (struct transform_s *ear, 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);
|
|
|
|
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2001-10-28 04:23:37 +00:00
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#endif//__QF_sound_h
|