Cube  Diff

Differences From Artifact [4f8b2c4c47]:

To Artifact [f6d08d4aed]:


1
2
3
4


5
6
7
8
9
10
11
// sound.cpp: uses fmod on windows and sdl_mixer on unix (both had problems on
// the other platform)

#include "cube.h"



// #ifndef _WIN32    // NOTE: fmod not being supported for the moment as it does
// not allow stereo pan/vol updating during playback
#define USE_MIXER
// #endif

VARP(soundvol, 0, 255, 255);




>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
// sound.cpp: uses fmod on windows and sdl_mixer on unix (both had problems on
// the other platform)

#include "cube.h"

#import "DynamicEntity.h"

// #ifndef _WIN32    // NOTE: fmod not being supported for the moment as it does
// not allow stereo pan/vol updating during playback
#define USE_MIXER
// #endif

VARP(soundvol, 0, 255, 255);
169
170
171
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187
188
189
190
191
192
193
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->o);
		vol -= (int)(dist * 3 * soundvol /
		    255); // simple mono distance attenuation
		if (stereo && (v.x != 0 || v.y != 0)) {

			float yaw = -atan2(v.x, v.y) -
			    player1->yaw *
			        (PI / 180.0f); // relative angle of
			                       // sound along X-Y axis
			pan = int(255.9f *
			    (0.5 * sin(yaw) + 0.5f)); // range is from 0 (left)
			                              // to 255 (right)
		}
	}
	vol = (vol * MAXVOL) / 255;
#ifdef USE_MIXER
	Mix_Volume(chan, vol);
	Mix_SetPanning(chan, 255 - pan, pan);
#else







|



>
|
<
|
|
|
<
<







171
172
173
174
175
176
177
178
179
180
181
182
183

184
185
186


187
188
189
190
191
192
193
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.o);
		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;
#ifdef USE_MIXER
	Mix_Volume(chan, vol);
	Mix_SetPanning(chan, 255 - pan, pan);
#else