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
|
VAR(stereo, 0, 1, 1);
static void
updatechanvol(int chan, const OFVector3D *loc)
{
int vol = soundvol, pan = 255 / 2;
if (loc) {
vdist(dist, v, *loc, player1.origin);
vol -= (int)(dist * 3 * soundvol /
255); // simple mono distance attenuation
if (stereo && (v.x != 0 || v.y != 0)) {
// relative angle of sound along X-Y axis
float yaw =
-atan2(v.x, v.y) - player1.yaw * (PI / 180.0f);
// range is from 0 (left) to 255 (right)
pan = (int)(255.9f * (0.5 * sin(yaw) + 0.5f));
}
}
vol = (vol * MAXVOL) / 255;
Mix_Volume(chan, vol);
Mix_SetPanning(chan, 255 - pan, pan);
}
static void
newsoundloc(int chan, const OFVector3D *loc)
|
>
|
>
>
>
>
|
|
>
|
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
|
VAR(stereo, 0, 1, 1);
static void
updatechanvol(int chan, const OFVector3D *loc)
{
int vol = soundvol, pan = 255 / 2;
if (loc) {
OFVector3D origin = player1.origin;
float dist = OFDistanceOfVectors3D(*loc, origin);
OFVector3D v = OFSubtractVectors3D(*loc, origin);
// simple mono distance attenuation
vol -= (int)(dist * 3 * soundvol / 255);
if (stereo && (v.x != 0 || v.y != 0)) {
// relative angle of sound along X-Y axis
float yaw =
-atan2(v.x, v.y) - player1.yaw * (PI / 180.0f);
// range is from 0 (left) to 255 (right)
pan = (int)(255.9f * (0.5 * sin(yaw) + 0.5f));
}
}
vol = (vol * MAXVOL) / 255;
Mix_Volume(chan, vol);
Mix_SetPanning(chan, 255 - pan, pan);
}
static void
newsoundloc(int chan, const OFVector3D *loc)
|