2009-08-07 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// sound.h - sndlib main header
|
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
|
|
#ifndef SOUND_H
|
|
|
|
|
#define SOUND_H
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include "launch_api.h"
|
|
|
|
|
#include "qfiles_ref.h"
|
2010-04-21 22:00:00 +02:00
|
|
|
|
#include "engine_api.h" // trace_t declaration
|
2009-08-07 22:00:00 +02:00
|
|
|
|
#include "vsound_api.h"
|
|
|
|
|
#include "s_openal.h"
|
|
|
|
|
|
|
|
|
|
extern stdlib_api_t com;
|
|
|
|
|
extern vsound_imp_t si;
|
|
|
|
|
extern byte *sndpool;
|
|
|
|
|
|
|
|
|
|
#include "mathlib.h"
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
S_OPENAL_110 = 0, // base
|
|
|
|
|
S_EXT_EFX,
|
|
|
|
|
S_EXT_I3DL,
|
|
|
|
|
S_EXT_EAX,
|
|
|
|
|
S_EXT_EAX20,
|
|
|
|
|
S_EXT_EAX30,
|
|
|
|
|
S_EXTCOUNT
|
|
|
|
|
} s_openal_extensions;
|
|
|
|
|
|
|
|
|
|
typedef struct sfx_s
|
|
|
|
|
{
|
|
|
|
|
string name;
|
|
|
|
|
bool loaded;
|
2010-04-24 22:00:00 +02:00
|
|
|
|
int loopStart; // looping point (in samples)
|
2009-08-07 22:00:00 +02:00
|
|
|
|
int samples;
|
|
|
|
|
int rate;
|
2010-04-24 22:00:00 +02:00
|
|
|
|
int sampleStep; // ( samples / rate ) * 100
|
2009-08-07 22:00:00 +02:00
|
|
|
|
uint format;
|
|
|
|
|
uint bufferNum;
|
|
|
|
|
|
2009-11-23 22:00:00 +01:00
|
|
|
|
int touchFrame;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
bool default_sound;
|
2009-11-23 22:00:00 +01:00
|
|
|
|
uint hashValue;
|
|
|
|
|
struct sfx_s *hashNext;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
} sfx_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
string loopName;
|
2010-04-27 22:00:00 +02:00
|
|
|
|
stream_t *intro_stream;
|
|
|
|
|
stream_t *main_stream; // mainstream he-he
|
|
|
|
|
bool active;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
} bg_track_t;
|
|
|
|
|
|
2009-12-06 22:00:00 +01:00
|
|
|
|
// structure used for fading in and out client sound volume.
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
float initial_percent;
|
|
|
|
|
float percent; // how far to adjust client's volume down by.
|
|
|
|
|
float starttime; // GetHostTime() when we started adjusting volume
|
|
|
|
|
float fadeouttime; // # of seconds to get to faded out state
|
|
|
|
|
float holdtime; // # of seconds to hold
|
|
|
|
|
float fadeintime; // # of seconds to restore
|
|
|
|
|
} soundfade_t;
|
|
|
|
|
|
2009-08-07 22:00:00 +02:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
sfx_t *sfx; // NULL if unused
|
2010-04-24 22:00:00 +02:00
|
|
|
|
|
2009-08-07 22:00:00 +02:00
|
|
|
|
int entnum; // to allow overriding a specific sound
|
|
|
|
|
int entchannel;
|
2010-06-17 22:00:00 +02:00
|
|
|
|
float startTime; // for overriding oldest sounds
|
2010-04-24 22:00:00 +02:00
|
|
|
|
bool staticsound; // use position instead of fetching entity's origin
|
2009-08-07 22:00:00 +02:00
|
|
|
|
vec3_t position; // only use if fixedPosition is set
|
|
|
|
|
float volume;
|
2010-04-24 22:00:00 +02:00
|
|
|
|
float pitch; // real-time pitch after any modulation or shift by dynamic data
|
|
|
|
|
float dist_mult;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
uint sourceNum; // openAL source
|
2010-04-24 22:00:00 +02:00
|
|
|
|
bool use_loop; // don't loop default and local sounds
|
|
|
|
|
bool isSentence; // bit who indicated sentence
|
2009-08-07 22:00:00 +02:00
|
|
|
|
} channel_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
vec3_t position;
|
|
|
|
|
vec3_t velocity;
|
|
|
|
|
float orientation[6];
|
2009-10-11 22:00:00 +02:00
|
|
|
|
int waterlevel;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
} listener_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *vendor_string;
|
|
|
|
|
const char *renderer_string;
|
|
|
|
|
const char *version_string;
|
|
|
|
|
const char *extensions_string;
|
|
|
|
|
|
|
|
|
|
byte extension[S_EXTCOUNT];
|
|
|
|
|
string deviceList[4];
|
|
|
|
|
const char *defDevice;
|
|
|
|
|
uint device_count;
|
|
|
|
|
uint num_slots;
|
|
|
|
|
uint num_sends;
|
|
|
|
|
|
|
|
|
|
bool allow_3DMode;
|
|
|
|
|
|
|
|
|
|
// 3d mode extension (eax or i3d)
|
|
|
|
|
int (*Set3DMode)( const guid_t*, uint, uint, void*, uint );
|
|
|
|
|
int (*Get3DMode)( const guid_t*, uint, uint, void*, uint );
|
|
|
|
|
} alconfig_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
aldevice *hDevice;
|
|
|
|
|
alcontext *hALC;
|
2009-10-06 22:00:00 +02:00
|
|
|
|
ref_params_t *refdef;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
bool initialized;
|
|
|
|
|
bool active;
|
2009-11-10 22:00:00 +01:00
|
|
|
|
bool paused;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
uint framecount;
|
2010-04-24 22:00:00 +02:00
|
|
|
|
int max_channels; // max channels that can be allocated by openAL
|
|
|
|
|
int total_channels; // total playing channels at current time
|
2009-08-07 22:00:00 +02:00
|
|
|
|
int clientnum;
|
|
|
|
|
} alstate_t;
|
|
|
|
|
|
2010-04-24 22:00:00 +02:00
|
|
|
|
extern alconfig_t al_config;
|
|
|
|
|
extern alstate_t al_state;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
|
2010-04-24 22:00:00 +02:00
|
|
|
|
#define Host_Error com.error
|
2009-08-07 22:00:00 +02:00
|
|
|
|
#define Z_Malloc( size ) Mem_Alloc( sndpool, size )
|
|
|
|
|
|
|
|
|
|
// cvars
|
|
|
|
|
extern cvar_t *s_alDevice;
|
2010-01-02 22:00:00 +01:00
|
|
|
|
extern cvar_t *s_allowEAX;
|
2009-08-07 22:00:00 +02:00
|
|
|
|
extern cvar_t *s_musicvolume;
|
|
|
|
|
extern cvar_t *s_check_errors;
|
|
|
|
|
|
2010-04-24 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
// s_load.c
|
|
|
|
|
//
|
|
|
|
|
bool S_TestSoundChar( const char *pch, char c );
|
|
|
|
|
char *S_SkipSoundChar( const char *pch );
|
2010-04-27 22:00:00 +02:00
|
|
|
|
uint S_GetFormat( int width, int channels );
|
2010-04-24 22:00:00 +02:00
|
|
|
|
|
2009-08-07 22:00:00 +02:00
|
|
|
|
bool S_Init( void *hInst );
|
|
|
|
|
void S_Shutdown( void );
|
|
|
|
|
void S_Activate( bool active );
|
|
|
|
|
void S_SoundList_f( void );
|
|
|
|
|
bool S_CheckForErrors( void );
|
2009-10-06 22:00:00 +02:00
|
|
|
|
void S_Update( ref_params_t *fd );
|
2010-04-21 22:00:00 +02:00
|
|
|
|
void S_StartSound( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags );
|
2010-04-24 22:00:00 +02:00
|
|
|
|
void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags );
|
2009-08-07 22:00:00 +02:00
|
|
|
|
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data );
|
|
|
|
|
void S_StartBackgroundTrack( const char *intro, const char *loop );
|
2010-04-24 22:00:00 +02:00
|
|
|
|
channel_t *SND_PickStaticChannel( int entnum, sfx_t *sfx );
|
|
|
|
|
channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx );
|
2009-11-25 22:00:00 +01:00
|
|
|
|
void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds );
|
2010-04-21 22:00:00 +02:00
|
|
|
|
int S_StartLocalSound( const char *name, float volume, int pitch, const float *org );
|
2009-08-07 22:00:00 +02:00
|
|
|
|
sfx_t *S_GetSfxByHandle( sound_t handle );
|
2010-04-24 22:00:00 +02:00
|
|
|
|
void S_StopSound( int entnum, int channel, const char *soundname );
|
2009-08-07 22:00:00 +02:00
|
|
|
|
void S_StreamBackgroundTrack( void );
|
|
|
|
|
void S_StopBackgroundTrack( void );
|
|
|
|
|
void S_ClearSoundBuffer( void );
|
|
|
|
|
bool S_LoadSound( sfx_t *sfx );
|
|
|
|
|
void S_StartStreaming( void );
|
|
|
|
|
void S_StopStreaming( void );
|
|
|
|
|
void S_StopAllSounds( void );
|
|
|
|
|
void S_FreeSounds( void );
|
|
|
|
|
|
|
|
|
|
// registration manager
|
|
|
|
|
void S_BeginRegistration( void );
|
|
|
|
|
sound_t S_RegisterSound( const char *sample );
|
|
|
|
|
void S_EndRegistration( void );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif//SOUND_H
|