/
sound.h
148 lines (124 loc) · 3.62 KB
/
sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: client sound i/o functions
//
//===========================================================================//
#ifndef SOUND_H
#define SOUND_H
#ifdef _WIN32
#pragma once
#endif
#include "basetypes.h"
#include "datamap.h"
#include "mathlib/vector.h"
#include "mathlib/mathlib.h"
#include "tier1/strtools.h"
#include "soundflags.h"
#include "utlvector.h"
#include "engine/SndInfo.h"
#define MAX_SFX 2048
#define AUDIOSOURCE_CACHE_ROOTDIR "maps/soundcache"
class CSfxTable;
enum soundlevel_t;
struct SoundInfo_t;
struct AudioState_t;
class IFileList;
void S_Init (void);
void S_Shutdown (void);
bool S_IsInitted();
void S_StopAllSounds(bool clear);
void S_Update( const AudioState_t *pAudioState );
void S_ExtraUpdate (void);
void S_ClearBuffer (void);
void S_BlockSound (void);
void S_UnblockSound (void);
float S_GetMasterVolume( void );
void S_SoundFade( float percent, float holdtime, float intime, float outtime );
void S_OnLoadScreen(bool value);
void S_EnableThreadedMixing( bool bEnable );
void S_EnableMusic( bool bEnable );
struct StartSoundParams_t
{
StartSoundParams_t() :
staticsound( false ),
userdata( 0 ),
soundsource( 0 ),
entchannel( CHAN_AUTO ),
pSfx( 0 ),
bUpdatePositions( true ),
fvol( 1.0f ),
soundlevel( SNDLVL_NORM ),
flags( SND_NOFLAGS ),
pitch( PITCH_NORM ),
fromserver( false ),
delay( 0.0f ),
speakerentity( -1 ),
suppressrecording( false ),
initialStreamPosition( 0 )
{
origin.Init();
direction.Init();
}
bool staticsound;
int userdata;
int soundsource;
int entchannel;
CSfxTable *pSfx;
Vector origin;
Vector direction;
bool bUpdatePositions;
float fvol;
soundlevel_t soundlevel;
int flags;
int pitch;
bool fromserver;
float delay;
int speakerentity;
bool suppressrecording;
int initialStreamPosition;
};
int S_StartSound( StartSoundParams_t& params );
void S_StopSound ( int entnum, int entchannel );
enum clocksync_index_t
{
CLOCK_SYNC_CLIENT = 0,
CLOCK_SYNC_SERVER,
NUM_CLOCK_SYNCS
};
extern float S_ComputeDelayForSoundtime( float soundtime, clocksync_index_t syncIndex );
void S_StopSoundByGuid( int guid );
float S_SoundDurationByGuid( int guid );
int S_GetGuidForLastSoundEmitted();
bool S_IsSoundStillPlaying( int guid );
void S_GetActiveSounds( CUtlVector< SndInfo_t >& sndlist );
void S_SetVolumeByGuid( int guid, float fvol );
float S_GetElapsedTimeByGuid( int guid );
bool S_IsLoopingSoundByGuid( int guid );
void S_ReloadSound( const char *pSample );
float S_GetMono16Samples( const char *pszName, CUtlVector< short >& sampleList );
CSfxTable *S_DummySfx( const char *name );
CSfxTable *S_PrecacheSound (const char *sample );
void S_PrefetchSound( char const *name, bool bPlayOnce );
void S_MarkUISound( CSfxTable *pSfx );
void S_ReloadFilesInList( IFileList *pFilesToReload );
vec_t S_GetNominalClipDist();
extern bool TestSoundChar(const char *pch, char c);
extern char *PSkipSoundChars(const char *pch);
#include "soundchars.h"
// for recording movies
void SND_MovieStart( void );
void SND_MovieEnd( void );
//-------------------------------------
int S_GetCurrentStaticSounds( SoundInfo_t *pResult, int nSizeResult, int entchannel );
//-----------------------------------------------------------------------------
float S_GetGainFromSoundLevel( soundlevel_t soundlevel, vec_t dist );
struct musicsave_t
{
DECLARE_SIMPLE_DATADESC();
char songname[ 128 ];
int sampleposition;
short master_volume;
};
void S_GetCurrentlyPlayingMusic( CUtlVector< musicsave_t >& list );
void S_RestartSong( const musicsave_t *song );
#endif // SOUND_H