Nuclide
Software Development Kit for id Tech
sound.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
28.float maxspeed;
29.float flags;
30
31var bool autocvar_s_developer = false;
32void
33_SndLog(string functionName, string msg)
34{
36 print(sprintf("^9%f ^xF50%s^7: %s\n", time, functionName, msg));
37 else
38 print(sprintf("^xF50%s^7: %s\n", functionName, msg));
39}
40
45#define SndLog(...) if (autocvar_s_developer) _SndLog(__FUNC__, sprintf(__VA_ARGS__))
46
47void
48_SndEntLog(string className, string functionName, float edictNum, string warnMessage)
49{
51 print(sprintf("^9%f ^xF50%s (id: %d)^7: %s\n", time, functionName, edictNum, warnMessage));
52 else
53 print(sprintf("^xF50%s (id: %d)^7: %s\n", functionName, edictNum, warnMessage));
54}
55
60#define SndEntLog(...) if (autocvar_s_developer) _SndEntLog(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
61
64
66typedef enumflags
67{
68 SNDFL_LOOPING,
69 SNDFL_NODUPS,
70 SNDFL_GLOBAL,
71 SNDFL_NOREVERB,
72 SNDFL_OMNI,
73 SNDFL_PRIVATE,
74 SNDFL_STEP,
75 SNDFL_FOLLOW,
76 SNDFL_ALERTS
77} soundFlag_t;
78
80typedef struct
81{
82 float dist_min;
83 float dist_max;
84 float offset;
85 float pitch_min;
86 float pitch_max;
87 float shakes;
88 float volume;
89 soundFlag_t flags;
90 int playc;
92 string samples;
93 string name;
94 string distshader;
96} snd_t;
97
99typedef struct
100{
101 string m_strSnd;
104} sound_t;
105
110
112void Sound_Init(void);
114void Sound_Shutdown(void);
116int Sound_Precache(string sndDef);
118void Sound_Play(entity targetEntity, int sndChannel, string sndDef);
120void Sound_PlayAt(vector worldPos, string sndDef);
121
122#ifdef CLIENT
124void Sound_PlayLocal(string shader);
126void Sound_Update(entity targetEntity, int sndChannel, int sndSample, float desiredVolume);
127
128int Sound_GetID(string sndDef);
129#else
131void Sound_Speak(entity targetEntity, string sentencesEntry);
132#endif
133
135void Sound_Stop(entity target, int chan);
136
137void Sound_DebugList();
#define hashtable
Definition: fteextensions.qc:269
float time
Definition: fteextensions.qc:509
vector(vector) normalize
entity() spawn
var bool autocvar_g_developerTimestamps
Definition: global.h:18
string target
Definition: defs.h:23
float flags
Definition: sound.h:29
void _SndLog(string functionName, string msg)
Definition: sound.h:33
int Sound_GetID(string sndDef)
Definition: sound.qc:777
void Sound_Update(entity targetEntity, int sndChannel, int sndSample, float desiredVolume)
Client-side only: Update the sound parameters on a given entity.
Definition: sound.qc:786
void Sound_Stop(entity target, int chan)
Stops sounds on a given channel, on a target entity.
Definition: sound.qc:568
int Sound_Precache(string sndDef)
Force the precache of a soundDef file.
Definition: sound.qc:380
float maxspeed
Definition: sound.h:28
snd_t * g_sounds
Pointer to the global soundDef table.
Definition: sound.h:107
void Sound_Play(entity targetEntity, int sndChannel, string sndDef)
Play a soundDef on a given target entity.
Definition: sound.qc:574
var bool autocvar_s_developer
Definition: sound.h:31
var hashtable g_hashsounds
Global hash table for name > soundDef id lookup.
Definition: sound.h:63
void Sound_PlayAt(vector worldPos, string sndDef)
Play a soundDef a a given location.
Definition: sound.qc:693
int g_sounds_count
Total amount of registered soundDef entries.
Definition: sound.h:109
void _SndEntLog(string className, string functionName, float edictNum, string warnMessage)
Definition: sound.h:48
void Sound_Shutdown(void)
Called by CSQC_Shutdown() and in theory, somewhere on the server.
Definition: sound.qc:37
void Sound_DebugList()
Called by listSoundDef.
Definition: sound.qc:934
void Sound_PlayLocal(string shader)
Client-side only: Play a sound locally, outside the game world.
Definition: sound.qc:751
void Sound_Init(void)
Called by the client inside CSQC_Init(), and on the server inside init().
Definition: sound.qc:50
typedef enumflags
Enumeration of valid sound flags.
Definition: sound.h:67
A soundDef aka 'sound shader' type.
Definition: sound.h:81
soundFlag_t flags
Sound flags that are applied to this soundDef.
Definition: sound.h:89
int playc
Number of plays.
Definition: sound.h:90
float dist_min
Minimum playback distance.
Definition: sound.h:82
int sample_count
Total amount of samples within this soundDef.
Definition: sound.h:91
float pitch_min
Minimum sound pitch.
Definition: sound.h:85
float offset
Sound sample offset.
Definition: sound.h:84
float pitch_max
Maximum sound pitch.
Definition: sound.h:86
float pointparticle
Definition: sound.h:95
float dist_max
Maximum playback distance.
Definition: sound.h:83
float shakes
Earthquake/Shake amplifier.
Definition: sound.h:87
string samples
Separated list of samples.
Definition: sound.h:92
string distshader
soundDef to play where this soundDef is not audible.
Definition: sound.h:94
float volume
Desired playback volume.
Definition: sound.h:88
string name
Name of the soundDef.
Definition: sound.h:93
A sound sample of a sentences.txt word sequence.
Definition: sound.h:100
string m_strSnd
Definition: sound.h:101
float m_flLength
Definition: sound.h:102
float m_flPitch
Definition: sound.h:103