]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sound.h
csqc: Implement builtin #177 "localsound"
[xonotic/darkplaces.git] / sound.h
diff --git a/sound.h b/sound.h
index 37e53b06f1e541983304a6a8e68603ca43184759..5a9a72dfb738decd52f953ebb82446582543bc54 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define SOUND_H
 
 #include "matrixlib.h"
+struct cmd_state_s;
 
 
 // ====================================================================
@@ -32,12 +33,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
 
 // Channel flags
-#define CHANNELFLAG_NONE               0
-#define CHANNELFLAG_FORCELOOP  (1 << 0) // force looping even if the sound is not looped
-#define CHANNELFLAG_LOCALSOUND (1 << 1) // INTERNAL USE. Not settable by S_SetChannelFlag
-#define CHANNELFLAG_PAUSED             (1 << 2)
-#define CHANNELFLAG_FULLVOLUME (1 << 3) // isn't affected by the general volume
-
+// These channel flags can be used for sound() builtins, with SOUNDFLAG_* names
+#define CHANNELFLAG_NONE       0
+#define CHANNELFLAG_RELIABLE   (1 << 0) // send as reliable message (only used on server)
+#define CHANNELFLAG_FORCELOOP  (1 << 1) // force looping even if the sound is not looped
+#define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
+#define CHANNELFLAG_PAUSED     (1 << 3) // pause status
+#define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume
 
 // ====================================================================
 // Types and variables
@@ -45,12 +47,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 typedef struct sfx_s sfx_t;
 
-extern cvar_t mastervolume;
-extern cvar_t bgmvolume;
-extern cvar_t volume;
-extern cvar_t snd_initialized;
-extern cvar_t snd_staticvolume;
-extern cvar_t snd_mutewhenidle;
+extern struct cvar_s mastervolume;
+extern struct cvar_s bgmvolume;
+extern struct cvar_s volume;
+extern struct cvar_s snd_initialized;
+extern struct cvar_s snd_staticvolume;
+extern struct cvar_s snd_mutewhenidle;
 
 
 // ====================================================================
@@ -62,30 +64,53 @@ void S_Terminate (void);
 
 void S_Startup (void);
 void S_Shutdown (void);
-void S_UnloadAllSounds_f (void);
+void S_UnloadAllSounds_f(struct cmd_state_s *cmd);
 
 void S_Update(const matrix4x4_t *listenermatrix);
 void S_ExtraUpdate (void);
 
-sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean serversound);
+sfx_t *S_PrecacheSound (const char *sample, qbool complain, qbool levelsound);
 float S_SoundLength(const char *name);
 void S_ClearUsed (void);
 void S_PurgeUnused (void);
-qboolean S_IsSoundPrecached (const sfx_t *sfx);
+qbool S_IsSoundPrecached (const sfx_t *sfx);
+sfx_t *S_FindName(const char *name);
+
+// these define the "engine" channel namespace
+#define CHAN_MIN_AUTO       -128
+#define CHAN_MAX_AUTO          0
+#define CHAN_MIN_SINGLE        1
+#define CHAN_MAX_SINGLE      127
+#define IS_CHAN_AUTO(n)        ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO)
+#define IS_CHAN_SINGLE(n)      ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE)
+#define IS_CHAN(n)             (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n))
+
+// engine channel == network channel
+#define CHAN_ENGINE2NET(c)     (c)
+#define CHAN_NET2ENGINE(c)     (c)
+
+// engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below)
+// user view uses the flags bitmask for it
+#define CHAN_USER2ENGINE(c)    (c)
+#define CHAN_ENGINE2USER(c)    (c)
+#define CHAN_ENGINE2CVAR(c)    (abs(c))
 
 // S_StartSound returns the channel index, or -1 if an error occurred
 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
-int S_StartSound_StartPosition (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition);
-qboolean S_LocalSound (const char *s);
+int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed);
+qbool S_LocalSoundEx (const char *s, int chan, float fvol);
+qbool S_LocalSound (const char *s);
 
 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
 void S_StopSound (int entnum, int entchannel);
 void S_StopAllSounds (void);
-void S_PauseGameSounds (qboolean toggle);
+void S_StopAllSounds_f(struct cmd_state_s *cmd);
+void S_PauseGameSounds (qbool toggle);
 
-void S_StopChannel (unsigned int channel_ind, qboolean lockmutex);
-qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value);
+void S_StopChannel (unsigned int channel_ind, qbool lockmutex, qbool freesfx);
+qbool S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qbool value);
 void S_SetChannelVolume (unsigned int ch_ind, float fvol);
+void S_SetChannelSpeed (unsigned int ch_ind, float fspeed);
 float S_GetChannelPosition (unsigned int ch_ind);
 float S_GetEntChannelPosition(int entnum, int entchannel);
 
@@ -94,5 +119,6 @@ void S_UnblockSound (void);
 
 int S_GetSoundRate (void);
 int S_GetSoundChannels (void);
+int S_GetSoundWidth (void);
 
 #endif