Nuclide
Software Development Kit for id Tech
NSSound.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 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
18public:
19 void NSSound( void );
20
21 nonvirtual void SetSample( string );
22 nonvirtual void SetVolume( float );
23 nonvirtual void SetRadius( float );
24 nonvirtual void SetSoundOffset( float );
25 nonvirtual void MakeOmniDirectional( void );
26 nonvirtual void MakeDirectional( void );
27 nonvirtual void EnableReverb( void );
28 nonvirtual void DisableReverb( void );
29 nonvirtual virtual void Play( void );
30
31private:
32 float m_radius;
33 float m_volume;
34 string m_sample;
35 bool m_omniDirectional;
36 float m_offset;
37};
38
39void NSSound::NSSound( void ) {
40 m_radius = 128.0f;
41 m_volume = 0.5f;
42 m_sample = "common/null.wav";
43}
44
45void NSSound::SetSample( string newSample ) {
46 m_sample = newSample;
47}
48
49void NSSound::SetVolume( float newVolume ) {
50 m_volume = newVolume;
51}
52
53void NSSound::SetRadius( float newRadius ) {
54 m_radius = newRadius;
55}
56
57void NSSound::SetSoundOffset( float newRadius ) {
58 m_offset = newRadius;
59}
60
62 m_omniDirectional = true;
63}
64
66 m_omniDirectional = false;
67}
68
70 m_ignoreReverb = false;
71}
72
74 m_ignoreReverb = true;
75}
76
77void NSSound::Play( void ) {
78 float soundFlags = 0;
79
80 if ( m_ignoreReverb ) {
81 soundFlags |= SOUNDFLAG_NOREVERB;
82 }
83#ifdef CLIENT
84 if ( m_omniDirectional ) {
85 soundFlags |= SOUNDFLAG_NOSPACIALISE;
86 }
87#endif
88
89 sound( this, CHAN_AUTO, m_sample, m_volume, m_radius, m_pitch, soundFlags, m_offset );
90}
This entity class represents point-entity triggers.
Definition: NSPointTrigger.h:26
Definition: NSSound.h:17
nonvirtual void MakeDirectional(void)
Definition: NSSound.h:65
nonvirtual void SetSoundOffset(float)
Definition: NSSound.h:57
nonvirtual void SetSample(string)
Definition: NSSound.h:45
nonvirtual void DisableReverb(void)
Definition: NSSound.h:73
void NSSound(void)
Definition: NSSound.h:39
nonvirtual void EnableReverb(void)
Definition: NSSound.h:69
nonvirtual void SetRadius(float)
Definition: NSSound.h:53
nonvirtual void SetVolume(float)
Definition: NSSound.h:49
nonvirtual void MakeOmniDirectional(void)
Definition: NSSound.h:61
virtual nonvirtual void Play(void)
Definition: NSSound.h:77