-
Notifications
You must be signed in to change notification settings - Fork 1
/
oal.h
153 lines (141 loc) · 3.87 KB
/
oal.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
149
150
151
152
153
#ifndef _OALSOUND_H_
#define _OALSOUND_H_
//#include "al.h"
//#include "alc.h"
#ifdef GGWINDOWS
#include <al/alut.h>
#endif //GGWINDOWS
#ifdef GGLINUX
#include </usr/include/AL/alut.h>
#endif //GGLINUX
//#define USE_SOUNDQUEUE
#define USE_SOUNDHEAP
#ifdef USE_SOUNDHEAP
const int MAX_SOUNDHEAP = 64;
#endif
#define MAX_SOUNDQUEUES (32)
#ifdef USE_SOUNDQUEUE
typedef struct t_soundqueue {
int start_ticks;
int time;
int param;
int diff;
float pos[3];
ALuint source;
float dist;
int table_ptr;
t_soundqueue *prev;
t_soundqueue *next;
} Soundqueue;
typedef struct t_soundqueue_memory {
int table[MAX_SOUNDQUEUES];
int ptr;
Soundqueue **s;
} Soundqueue_memory;
#endif //USE_SOUNDQUEUE
#ifdef USE_SOUNDHEAP
typedef struct t_soundheap {
int start_ticks;
int play_ticks;
unsigned int source;
int param;
Flt dist;
float pos[3];
} Soundheap;
#endif //USE_SOUNDHEAP
class gp_Sound {
public:
gp_Sound();
~gp_Sound() { }
public:
int onOff;
int errorflag;
int listener_interval;
#ifdef USE_SOUNDQUEUE
Soundqueue *soundqueue_head;
#endif //USE_SOUNDQUEUE
#ifdef USE_SOUNDHEAP
Soundheap *soundheap;
int nSoundheap;
#endif //USE_SOUNDHEAP
ALuint alSourceLanderExhaust;
ALuint alSourceHardLandingGround;
ALuint alSourceSoftLandingGround;
ALuint alSourceHardLandingLz;
ALuint alSourceSoftLandingLz;
ALuint alSourceSoftBounce[8];
ALuint alSourceHardBounce[8];
ALuint alSourceEngineOff;
ALuint alSourceTick;
ALuint alSourceSlurp;
ALuint alSourceDing;
ALuint alSourceCannon;
ALuint alSourceScore1;
ALuint alSourceGroundhit;
ALuint alSourceNukeExplosion;
ALuint alSourcePortalBounce;
ALuint alSourceTetraExplode;
ALuint alSourceRover;
ALuint alSourceGlider;
ALuint alSourceRico;
ALuint alSourceArchbump;
ALuint alSourceOuch;
//
float doppler_factor;
float doppler_velocity;
ALuint alCurrentLanderEngine;
static const int nsoftbounce=5;
static const int nhardbounce=3;
int nsoundqueues;
int nsources;
int nsoundson;
int nsoundsoff;
int nsoundslooping;
int update_pitch;
int setup_ticks;
float listenerPos[3], listenerOri[6];
#ifdef USE_SOUNDQUEUE
Soundqueue_memory soundqueue_memory;
void check_sound_queue(void);
void delete_soundqueue(Soundqueue *s);
void insert_soundqueue(const Vec pos, const unsigned int ssource);
Soundqueue * get_soundqueue_mem(void);
void setup_soundqueue_memory(void);
#endif //USE_SOUNDQUEUE
#ifdef USE_SOUNDHEAP
void verifyHeap();
//void heapDownDesc(int start, int end);
void percolateDown(int node);
void percolateUp(int node);
//void heapUpDesc(int child);
void soundheapIns(const Vec pos, const unsigned int ssource);
void soundheapCheck();
#endif //USE_SOUNDHEAP
void turn_sound_on(int alutinit);
void turn_sound_off(void);
void set_source_properties(const ALuint source, const float maxdist, const float roff, const float min_volume, const float max_volume);
void play_a_sound(ALuint source);
void play_a_bounce(const Vec pos, const Flt movement, const Flt threshold);
void stop_a_sound(ALuint source);
void set_volume(const ALuint source, const float vlevel); // vlevel: 0.0 - 1.0
void adjust_volume(const ALuint source, const float dist);
void set_listener();
void my_load_wav(const char *fname, unsigned char *wavmem, int len, ALuint *source);
void load_sound(const char *wavfilename, unsigned char *wavmem, int looping, float pitch, float gain);
//void insert_into_sound_queue(int distance, const Vec pos, unsigned int ssource, int btime);
void make_wav_mem_image(const char *fname, const int flag);
void record_sounds(void);
//void load_nuke_wav(void);
void set_engine_sound(const int flag);
void play_sound_var_pitch(const ALuint source);
void startup_sound(void);
void sound_set(void);
ALCcontext *recContext;
ALCdevice *recDevice;
ALCdevice *recCaptureDevice;
int recNumber, recSum, recRecTime, recRecordNow, recTracks, recResolution;
int recSamplesAvailable;
int recWholeMemorySpace;
char *recAmem;
};
#endif //_OALSOUND_H_