2002-06-13 21:15:06 +02:00
|
|
|
/* DirectSound
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Rob Riggs
|
|
|
|
* Copyright 2000-2001 TransGaming Technologies, Inc.
|
2003-02-17 02:46:46 +01:00
|
|
|
* Copyright 2002-2003 Rok Mandeljc <rok.mandeljc@gimb.org>
|
2002-06-13 21:15:06 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Most thread locking is complete. There may be a few race
|
|
|
|
* conditions still lurking.
|
|
|
|
*
|
|
|
|
* Tested with a Soundblaster clone, a Gravis UltraSound Classic,
|
|
|
|
* and a Turtle Beach Tropez+.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Implement SetCooperativeLevel properly (need to address focus issues)
|
|
|
|
* Implement DirectSound3DBuffers (stubs in place)
|
|
|
|
* Use hardware 3D support if available
|
|
|
|
* Add critical section locking inside Release and AddRef methods
|
|
|
|
* Handle static buffers - put those in hardware, non-static not in hardware
|
|
|
|
* Hardware DuplicateSoundBuffer
|
|
|
|
* Proper volume calculation, and setting volume in HEL primary buffer
|
|
|
|
* Optimize WINMM and negotiate fragment size, decrease DS_HEL_MARGIN
|
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-06-13 21:15:06 +02:00
|
|
|
#include <math.h> /* Insomnia - pow() function */
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-17 11:24:50 +02:00
|
|
|
#include "winuser.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmsystem.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmddk.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
|
|
|
#include "dsound_private.h"
|
|
|
|
|
2003-03-31 03:34:08 +02:00
|
|
|
/* default velocity of sound in the air */
|
|
|
|
#define DEFAULT_VELOCITY 340
|
2003-02-17 02:46:46 +01:00
|
|
|
|
2003-01-04 02:24:59 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound3d);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-01-04 02:22:51 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Auxiliary functions
|
|
|
|
*/
|
|
|
|
|
2011-08-03 23:50:18 +02:00
|
|
|
/* scalar product (I believe it's called dot product in English) */
|
2007-04-28 16:39:28 +02:00
|
|
|
static inline D3DVALUE ScalarProduct (const D3DVECTOR *a, const D3DVECTOR *b)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
|
|
|
D3DVALUE c;
|
2003-09-06 01:08:26 +02:00
|
|
|
c = (a->x*b->x) + (a->y*b->y) + (a->z*b->z);
|
2007-01-09 00:39:23 +01:00
|
|
|
TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a->x, a->y, a->z, b->x, b->y,
|
2003-09-06 01:08:26 +02:00
|
|
|
b->z, c);
|
2003-01-04 02:22:51 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2011-08-03 23:50:18 +02:00
|
|
|
/* vector product (I believe it's called cross product in English */
|
2007-04-28 16:39:28 +02:00
|
|
|
static inline D3DVECTOR VectorProduct (const D3DVECTOR *a, const D3DVECTOR *b)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVECTOR c;
|
2003-09-06 01:08:26 +02:00
|
|
|
c.x = (a->y*b->z) - (a->z*b->y);
|
|
|
|
c.y = (a->z*b->x) - (a->x*b->z);
|
|
|
|
c.z = (a->x*b->y) - (a->y*b->x);
|
2007-01-09 00:39:23 +01:00
|
|
|
TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a->x, a->y, a->z, b->x, b->y,
|
2003-09-06 01:08:26 +02:00
|
|
|
b->z, c.x, c.y, c.z);
|
2003-01-04 02:22:51 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2003-07-09 04:52:57 +02:00
|
|
|
/* magnitude (length) of vector */
|
2007-04-28 16:39:28 +02:00
|
|
|
static inline D3DVALUE VectorMagnitude (const D3DVECTOR *a)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
|
|
|
D3DVALUE l;
|
|
|
|
l = sqrt (ScalarProduct (a, a));
|
2003-09-06 01:08:26 +02:00
|
|
|
TRACE("|(%f,%f,%f)| = %f\n", a->x, a->y, a->z, l);
|
2003-01-04 02:22:51 +01:00
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* conversion between radians and degrees */
|
2003-03-10 20:06:02 +01:00
|
|
|
static inline D3DVALUE RadToDeg (D3DVALUE angle)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVALUE newangle;
|
2003-01-04 02:22:51 +01:00
|
|
|
newangle = angle * (360/(2*M_PI));
|
2003-03-10 20:06:02 +01:00
|
|
|
TRACE("%f rad = %f deg\n", angle, newangle);
|
2003-01-04 02:22:51 +01:00
|
|
|
return newangle;
|
|
|
|
}
|
|
|
|
|
2007-11-09 20:12:09 +01:00
|
|
|
/* angle between vectors - rad version */
|
|
|
|
static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECTOR *b)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVALUE la, lb, product, angle, cos;
|
2008-11-25 17:42:38 +01:00
|
|
|
/* definition of scalar product: a*b = |a|*|b|*cos... therefore: */
|
2003-01-04 02:22:51 +01:00
|
|
|
product = ScalarProduct (a,b);
|
|
|
|
la = VectorMagnitude (a);
|
|
|
|
lb = VectorMagnitude (b);
|
2007-11-09 20:13:01 +01:00
|
|
|
if (!la || !lb)
|
|
|
|
return 0;
|
|
|
|
|
2003-01-04 02:22:51 +01:00
|
|
|
cos = product/(la*lb);
|
2003-03-10 20:06:02 +01:00
|
|
|
angle = acos(cos);
|
2007-11-09 20:12:09 +01:00
|
|
|
TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n", a->x, a->y, a->z, b->x,
|
|
|
|
b->y, b->z, angle, RadToDeg(angle));
|
2003-03-10 20:06:02 +01:00
|
|
|
return angle;
|
|
|
|
}
|
|
|
|
|
2007-11-09 20:12:09 +01:00
|
|
|
static inline D3DVALUE AngleBetweenVectorsDeg (const D3DVECTOR *a, const D3DVECTOR *b)
|
2003-03-10 20:06:02 +01:00
|
|
|
{
|
2007-11-09 20:12:09 +01:00
|
|
|
return RadToDeg(AngleBetweenVectorsRad(a, b));
|
2003-01-04 02:22:51 +01:00
|
|
|
}
|
|
|
|
|
2003-01-04 02:24:59 +01:00
|
|
|
/* calculates vector between two points */
|
2007-04-28 16:39:28 +02:00
|
|
|
static inline D3DVECTOR VectorBetweenTwoPoints (const D3DVECTOR *a, const D3DVECTOR *b)
|
2003-01-04 02:24:59 +01:00
|
|
|
{
|
|
|
|
D3DVECTOR c;
|
2003-09-06 01:08:26 +02:00
|
|
|
c.x = b->x - a->x;
|
|
|
|
c.y = b->y - a->y;
|
|
|
|
c.z = b->z - a->z;
|
|
|
|
TRACE("A (%f,%f,%f), B (%f,%f,%f), AB = (%f,%f,%f)\n", a->x, a->y, a->z, b->x, b->y,
|
|
|
|
b->z, c.x, c.y, c.z);
|
2003-01-04 02:24:59 +01:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
/* calculates the length of vector's projection on another vector */
|
2007-04-28 16:39:28 +02:00
|
|
|
static inline D3DVALUE ProjectVector (const D3DVECTOR *a, const D3DVECTOR *p)
|
2003-03-31 03:34:08 +02:00
|
|
|
{
|
|
|
|
D3DVALUE prod, result;
|
|
|
|
prod = ScalarProduct(a, p);
|
|
|
|
result = prod/VectorMagnitude(p);
|
2003-09-06 01:08:26 +02:00
|
|
|
TRACE("length projection of (%f,%f,%f) on (%f,%f,%f) = %f\n", a->x, a->y, a->z, p->x,
|
|
|
|
p->y, p->z, result);
|
2003-03-31 03:34:08 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-01-04 02:22:51 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* 3D Buffer and Listener mixing
|
|
|
|
*/
|
2003-01-04 02:24:59 +01:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
2003-01-10 02:46:36 +01:00
|
|
|
/* volume, at which the sound will be played after all calcs. */
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVALUE lVolume = 0;
|
2003-01-10 02:46:36 +01:00
|
|
|
/* stuff for distance related stuff calc. */
|
2003-01-04 02:24:59 +01:00
|
|
|
D3DVECTOR vDistance;
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVALUE flDistance = 0;
|
|
|
|
/* panning related stuff */
|
2015-01-06 20:27:00 +01:00
|
|
|
D3DVALUE flAngle, flAngle2;
|
2003-03-10 20:06:02 +01:00
|
|
|
D3DVECTOR vLeft;
|
2015-01-06 20:27:21 +01:00
|
|
|
int i, num_main_speakers;
|
2015-01-06 20:27:00 +01:00
|
|
|
float a, ingain;
|
2003-03-31 03:34:08 +02:00
|
|
|
/* doppler shift related stuff */
|
2003-04-05 00:13:02 +02:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
TRACE("(%p)\n",dsb);
|
2003-02-17 02:46:46 +01:00
|
|
|
|
2003-03-10 20:06:02 +01:00
|
|
|
/* initial buffer volume */
|
2004-07-14 01:35:09 +02:00
|
|
|
lVolume = dsb->ds3db_lVolume;
|
2003-01-04 02:24:59 +01:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
switch (dsb->ds3db_ds3db.dwMode)
|
2003-01-04 02:24:59 +01:00
|
|
|
{
|
|
|
|
case DS3DMODE_NORMAL:
|
2003-03-05 03:47:39 +01:00
|
|
|
TRACE("Normal 3D processing mode\n");
|
|
|
|
/* we need to calculate distance between buffer and listener*/
|
2015-02-03 00:55:39 +01:00
|
|
|
vDistance = VectorBetweenTwoPoints(&dsb->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
|
2003-02-17 02:46:46 +01:00
|
|
|
flDistance = VectorMagnitude (&vDistance);
|
2003-01-10 02:46:36 +01:00
|
|
|
break;
|
2003-01-04 02:24:59 +01:00
|
|
|
case DS3DMODE_HEADRELATIVE:
|
2003-03-05 03:47:39 +01:00
|
|
|
TRACE("Head-relative 3D processing mode\n");
|
|
|
|
/* distance between buffer and listener is same as buffer's position */
|
2015-02-03 00:55:39 +01:00
|
|
|
vDistance = dsb->ds3db_ds3db.vPosition;
|
|
|
|
flDistance = VectorMagnitude (&vDistance);
|
2003-03-10 20:06:02 +01:00
|
|
|
break;
|
2016-02-10 19:54:15 +01:00
|
|
|
default:
|
|
|
|
TRACE("3D processing disabled\n");
|
|
|
|
/* this one is here only to eliminate annoying warning message */
|
2016-12-28 21:03:25 +01:00
|
|
|
dsb->volpan.lVolume = dsb->ds3db_lVolume;
|
2016-02-10 19:54:15 +01:00
|
|
|
DSOUND_RecalcVolPan (&dsb->volpan);
|
|
|
|
return;
|
2003-03-10 20:06:02 +01:00
|
|
|
}
|
2003-03-05 03:47:39 +01:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
if (flDistance > dsb->ds3db_ds3db.flMaxDistance)
|
2003-03-05 03:47:39 +01:00
|
|
|
{
|
|
|
|
/* some apps don't want you to hear too distant sounds... */
|
2003-06-28 00:22:15 +02:00
|
|
|
if (dsb->dsbd.dwFlags & DSBCAPS_MUTE3DATMAXDISTANCE)
|
2003-03-05 03:47:39 +01:00
|
|
|
{
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->volpan.lVolume = DSBVOLUME_MIN;
|
|
|
|
DSOUND_RecalcVolPan (&dsb->volpan);
|
2003-03-05 03:47:39 +01:00
|
|
|
/* i guess mixing here would be a waste of power */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2003-06-28 00:22:15 +02:00
|
|
|
flDistance = dsb->ds3db_ds3db.flMaxDistance;
|
2003-03-05 03:47:39 +01:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
if (flDistance < dsb->ds3db_ds3db.flMinDistance)
|
|
|
|
flDistance = dsb->ds3db_ds3db.flMinDistance;
|
2016-12-28 21:02:54 +01:00
|
|
|
|
|
|
|
flDistance = dsb->ds3db_ds3db.flMinDistance + (flDistance - dsb->ds3db_ds3db.flMinDistance) * dsb->device->ds3dl.flRolloffFactor;
|
2003-03-05 03:47:39 +01:00
|
|
|
|
2007-07-05 19:30:18 +02:00
|
|
|
/* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
|
2016-12-28 21:02:54 +01:00
|
|
|
lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
|
2003-03-10 20:06:02 +01:00
|
|
|
|
|
|
|
/* conning */
|
|
|
|
/* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
|
2003-09-06 01:08:26 +02:00
|
|
|
if (dsb->ds3db_ds3db.vConeOrientation.x == 0 && dsb->ds3db_ds3db.vConeOrientation.y == 0 && dsb->ds3db_ds3db.vConeOrientation.z == 0)
|
2003-03-10 20:06:02 +01:00
|
|
|
{
|
|
|
|
TRACE("conning: cones not set\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-03 00:55:39 +01:00
|
|
|
D3DVECTOR vDistanceInv;
|
|
|
|
|
|
|
|
vDistanceInv.x = -vDistance.x;
|
|
|
|
vDistanceInv.y = -vDistance.y;
|
|
|
|
vDistanceInv.z = -vDistance.z;
|
|
|
|
|
2003-03-10 20:06:02 +01:00
|
|
|
/* calculate angle */
|
2015-02-03 00:55:39 +01:00
|
|
|
flAngle = AngleBetweenVectorsDeg(&dsb->ds3db_ds3db.vConeOrientation, &vDistanceInv);
|
2003-03-10 20:06:02 +01:00
|
|
|
/* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
|
2003-06-28 00:22:15 +02:00
|
|
|
if (dsb->ds3db_ds3db.dwInsideConeAngle != dsb->ds3db_ds3db.dwOutsideConeAngle)
|
2003-03-10 20:06:02 +01:00
|
|
|
{
|
|
|
|
/* my test show that for my way of calc., we need only half of angles */
|
2003-06-28 00:22:15 +02:00
|
|
|
DWORD dwInsideConeAngle = dsb->ds3db_ds3db.dwInsideConeAngle/2;
|
|
|
|
DWORD dwOutsideConeAngle = dsb->ds3db_ds3db.dwOutsideConeAngle/2;
|
2007-07-08 16:38:05 +02:00
|
|
|
if (dwOutsideConeAngle == dwInsideConeAngle)
|
|
|
|
++dwOutsideConeAngle;
|
|
|
|
|
2003-03-10 20:06:02 +01:00
|
|
|
/* full volume */
|
|
|
|
if (flAngle < dwInsideConeAngle)
|
|
|
|
flAngle = dwInsideConeAngle;
|
|
|
|
/* min (app defined) volume */
|
|
|
|
if (flAngle > dwOutsideConeAngle)
|
|
|
|
flAngle = dwOutsideConeAngle;
|
|
|
|
/* this probably isn't the right thing, but it's ok for the time being */
|
2015-04-11 17:44:14 +02:00
|
|
|
lVolume += ((flAngle - dwInsideConeAngle)/(dwOutsideConeAngle - dwInsideConeAngle)) * dsb->ds3db_ds3db.lConeOutsideVolume;
|
2003-06-28 00:22:15 +02:00
|
|
|
}
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %d deg; OutsideConeAngle(/2) = %d deg; ConeOutsideVolume = %d => adjusting volume to %f\n",
|
2003-06-28 00:22:15 +02:00
|
|
|
flAngle, dsb->ds3db_ds3db.dwInsideConeAngle/2, dsb->ds3db_ds3db.dwOutsideConeAngle/2, dsb->ds3db_ds3db.lConeOutsideVolume, lVolume);
|
2003-03-10 20:06:02 +01:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->volpan.lVolume = lVolume;
|
2015-01-06 20:27:00 +01:00
|
|
|
|
|
|
|
ingain = pow(2.0, dsb->volpan.lVolume / 600.0) * 0xffff;
|
|
|
|
|
|
|
|
if (dsb->device->pwfx->nChannels == 1)
|
|
|
|
{
|
|
|
|
dsb->volpan.dwTotalAmpFactor[0] = ingain;
|
|
|
|
return;
|
|
|
|
}
|
2003-03-10 20:06:02 +01:00
|
|
|
|
|
|
|
/* panning */
|
2015-02-03 00:55:39 +01:00
|
|
|
if (vDistance.x == 0.0f && vDistance.y == 0.0f && vDistance.z == 0.0f)
|
2003-06-28 00:22:15 +02:00
|
|
|
flAngle = 0.0;
|
|
|
|
else
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop);
|
2015-03-22 16:22:49 +01:00
|
|
|
/* To calculate angle to sound source we need to:
|
|
|
|
* 1) Get angle between vDistance and a plane on which angle to sound source should be 0.
|
|
|
|
* Such a plane is given by vectors vOrientFront and vOrientTop, and angle between vector
|
|
|
|
* and a plane equals to M_PI_2 - angle between vector and normal to this plane (vLeft in this case).
|
|
|
|
* 2) Determine if the source is behind or in front of us by calculating angle between vDistance
|
|
|
|
* and vOrientFront.
|
|
|
|
*/
|
|
|
|
flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance);
|
|
|
|
flAngle2 = AngleBetweenVectorsRad(&dsb->device->ds3dl.vOrientFront, &vDistance);
|
|
|
|
if (flAngle2 > M_PI_2)
|
|
|
|
flAngle = -flAngle;
|
|
|
|
flAngle -= M_PI_2;
|
|
|
|
if (flAngle < -M_PI)
|
|
|
|
flAngle += 2*M_PI;
|
2003-06-28 00:22:15 +02:00
|
|
|
}
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("panning: Angle = %f rad, lPan = %d\n", flAngle, dsb->volpan.lPan);
|
2003-03-31 03:34:08 +02:00
|
|
|
|
|
|
|
/* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
|
2011-12-25 19:23:39 +01:00
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
D3DVALUE flFreq, flBufferVel, flListenerVel;
|
2003-03-10 20:06:02 +01:00
|
|
|
/* doppler shift*/
|
2011-12-25 19:23:39 +01:00
|
|
|
if (!VectorMagnitude(&dsb->ds3db_ds3db.vVelocity) && !VectorMagnitude(&dsb->device->ds3dl.vVelocity))
|
2003-03-31 03:34:08 +02:00
|
|
|
{
|
|
|
|
TRACE("doppler: Buffer and Listener don't have velocities\n");
|
|
|
|
}
|
2011-12-25 19:23:39 +01:00
|
|
|
else if (!(dsb->ds3db_ds3db.vVelocity.x == dsb->device->ds3dl.vVelocity.x &&
|
|
|
|
dsb->ds3db_ds3db.vVelocity.y == dsb->device->ds3dl.vVelocity.y &&
|
|
|
|
dsb->ds3db_ds3db.vVelocity.z == dsb->device->ds3dl.vVelocity.z))
|
2003-03-31 03:34:08 +02:00
|
|
|
{
|
2007-07-05 19:32:18 +02:00
|
|
|
/* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect
|
2016-08-04 09:57:43 +02:00
|
|
|
NOTE: if buffer moves TOWARDS the listener, its velocity component is NEGATIVE
|
|
|
|
if buffer moves AWAY from listener, its velocity component is POSITIVE */
|
2003-06-28 00:22:15 +02:00
|
|
|
flBufferVel = ProjectVector(&dsb->ds3db_ds3db.vVelocity, &vDistance);
|
2003-07-09 04:52:57 +02:00
|
|
|
/* calculate length of ds3dl.vVelocity component which causes Doppler Effect
|
2016-08-04 09:57:43 +02:00
|
|
|
NOTE: if listener moves TOWARDS the buffer, its velocity component is POSITIVE
|
|
|
|
if listener moves AWAY from buffer, its velocity component is NEGATIVE */
|
2006-01-06 12:35:20 +01:00
|
|
|
flListenerVel = ProjectVector(&dsb->device->ds3dl.vVelocity, &vDistance);
|
2003-03-31 03:34:08 +02:00
|
|
|
/* formula taken from Gianicoli D.: Physics, 4th edition: */
|
2003-06-28 00:22:15 +02:00
|
|
|
/* FIXME: replace dsb->freq with appropriate frequency ! */
|
|
|
|
flFreq = dsb->freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel));
|
2011-12-25 19:23:39 +01:00
|
|
|
TRACE("doppler: Buffer velocity (component) = %f, Listener velocity (component) = %f => Doppler shift: %d Hz -> %f Hz\n",
|
|
|
|
flBufferVel, flListenerVel, dsb->freq, flFreq);
|
2003-03-31 03:34:08 +02:00
|
|
|
/* FIXME: replace following line with correct frequency setting ! */
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->freq = flFreq;
|
2007-07-29 23:47:01 +02:00
|
|
|
DSOUND_RecalcFormat(dsb);
|
2003-03-31 03:34:08 +02:00
|
|
|
}
|
2011-12-25 19:23:39 +01:00
|
|
|
}
|
2015-01-06 20:27:00 +01:00
|
|
|
|
|
|
|
for (i = 0; i < dsb->device->pwfx->nChannels; i++)
|
|
|
|
dsb->volpan.dwTotalAmpFactor[i] = 0;
|
|
|
|
|
2015-01-06 20:27:21 +01:00
|
|
|
num_main_speakers = dsb->device->pwfx->nChannels;
|
|
|
|
|
|
|
|
if (dsb->device->lfe_channel != -1) {
|
|
|
|
dsb->volpan.dwTotalAmpFactor[dsb->device->lfe_channel] = ingain;
|
|
|
|
num_main_speakers--;
|
|
|
|
}
|
|
|
|
|
2015-01-06 20:27:00 +01:00
|
|
|
/* adapted from OpenAL's Alc/panning.c */
|
2015-01-06 20:27:21 +01:00
|
|
|
for (i = 0; i < num_main_speakers - 1; i++)
|
2015-01-06 20:27:00 +01:00
|
|
|
{
|
|
|
|
if(flAngle >= dsb->device->speaker_angles[i] && flAngle < dsb->device->speaker_angles[i+1])
|
|
|
|
{
|
|
|
|
/* Sound is between speakers i and i+1 */
|
|
|
|
a = (flAngle-dsb->device->speaker_angles[i]) / (dsb->device->speaker_angles[i+1]-dsb->device->speaker_angles[i]);
|
|
|
|
dsb->volpan.dwTotalAmpFactor[dsb->device->speaker_num[i]] = sqrtf(1.0f-a) * ingain;
|
|
|
|
dsb->volpan.dwTotalAmpFactor[dsb->device->speaker_num[i+1]] = sqrtf(a) * ingain;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sound is between last and first speakers */
|
|
|
|
if (flAngle < dsb->device->speaker_angles[0]) { flAngle += M_PI*2.0f; }
|
|
|
|
a = (flAngle-dsb->device->speaker_angles[i]) / (M_PI*2.0f + dsb->device->speaker_angles[0]-dsb->device->speaker_angles[i]);
|
|
|
|
dsb->volpan.dwTotalAmpFactor[dsb->device->speaker_num[i]] = sqrtf(1.0f-a) * ingain;
|
|
|
|
dsb->volpan.dwTotalAmpFactor[dsb->device->speaker_num[0]] = sqrtf(a) * ingain;
|
2003-06-28 00:22:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl *dsb)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",dsb);
|
|
|
|
|
|
|
|
DSOUND_Calc3DBuffer(dsb);
|
2003-01-04 02:22:51 +01:00
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static void DSOUND_ChangeListener(IDirectSoundBufferImpl *ds3dl)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
|
|
|
int i;
|
2003-05-22 05:39:13 +02:00
|
|
|
TRACE("(%p)\n",ds3dl);
|
2006-01-06 12:35:20 +01:00
|
|
|
for (i = 0; i < ds3dl->device->nrofbuffers; i++)
|
2003-01-04 02:22:51 +01:00
|
|
|
{
|
2007-06-13 17:05:49 +02:00
|
|
|
/* check if this buffer is waiting for recalculation */
|
2006-01-06 12:35:20 +01:00
|
|
|
if (ds3dl->device->buffers[i]->ds3db_need_recalc)
|
2003-01-04 02:24:59 +01:00
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
DSOUND_Mix3DBuffer(ds3dl->device->buffers[i]);
|
2003-01-04 02:24:59 +01:00
|
|
|
}
|
2003-01-04 02:22:51 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound3DBuffer
|
|
|
|
*/
|
2012-01-19 01:18:30 +01:00
|
|
|
static inline IDirectSoundBufferImpl *impl_from_IDirectSound3DBuffer(IDirectSound3DBuffer *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectSoundBufferImpl, IDirectSound3DBuffer_iface);
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* IUnknown methods */
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_QueryInterface(IDirectSound3DBuffer *iface,
|
|
|
|
REFIID riid, void **ppobj)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2012-01-19 01:18:30 +01:00
|
|
|
return IDirectSoundBuffer8_QueryInterface(&This->IDirectSoundBuffer8_iface, riid, ppobj);
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static ULONG WINAPI IDirectSound3DBufferImpl_AddRef(IDirectSound3DBuffer *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref3D);
|
2011-08-25 23:42:44 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2011-08-25 23:42:44 +02:00
|
|
|
|
|
|
|
if(ref == 1)
|
2012-01-19 01:18:30 +01:00
|
|
|
InterlockedIncrement(&This->numIfaces);
|
2011-08-25 23:42:44 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static ULONG WINAPI IDirectSound3DBufferImpl_Release(IDirectSound3DBuffer *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref3D);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2012-01-19 01:18:30 +01:00
|
|
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
|
|
|
secondarybuffer_destroy(This);
|
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirectSound3DBuffer methods */
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetAllParameters(IDirectSound3DBuffer *iface,
|
|
|
|
DS3DBUFFER *lpDs3dBuffer)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
TRACE("(%p,%p)\n",This,lpDs3dBuffer);
|
|
|
|
|
|
|
|
if (lpDs3dBuffer == NULL) {
|
2003-07-02 06:37:26 +02:00
|
|
|
WARN("invalid parameter: lpDs3dBuffer == NULL\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDs3dBuffer->dwSize < sizeof(*lpDs3dBuffer)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: lpDs3dBuffer->dwSize = %d\n",lpDs3dBuffer->dwSize);
|
2003-06-28 00:22:15 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2003-09-02 02:56:14 +02:00
|
|
|
TRACE("returning: all parameters\n");
|
2012-01-19 01:18:30 +01:00
|
|
|
*lpDs3dBuffer = This->ds3db_ds3db;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeAngles(IDirectSound3DBuffer *iface,
|
|
|
|
DWORD *lpdwInsideConeAngle, DWORD *lpdwOutsideConeAngle)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Inside Cone Angle = %d degrees; Outside Cone Angle = %d degrees\n",
|
|
|
|
This->ds3db_ds3db.dwInsideConeAngle, This->ds3db_ds3db.dwOutsideConeAngle);
|
|
|
|
*lpdwInsideConeAngle = This->ds3db_ds3db.dwInsideConeAngle;
|
|
|
|
*lpdwOutsideConeAngle = This->ds3db_ds3db.dwOutsideConeAngle;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeOrientation(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVECTOR *lpvConeOrientation)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Cone Orientation vector = (%f,%f,%f)\n",
|
|
|
|
This->ds3db_ds3db.vConeOrientation.x,
|
|
|
|
This->ds3db_ds3db.vConeOrientation.y,
|
|
|
|
This->ds3db_ds3db.vConeOrientation.z);
|
|
|
|
*lpvConeOrientation = This->ds3db_ds3db.vConeOrientation;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeOutsideVolume(IDirectSound3DBuffer *iface,
|
|
|
|
LONG *lplConeOutsideVolume)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Cone Outside Volume = %d\n", This->ds3db_ds3db.lConeOutsideVolume);
|
|
|
|
*lplConeOutsideVolume = This->ds3db_ds3db.lConeOutsideVolume;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetMaxDistance(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE *lpfMaxDistance)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Max Distance = %f\n", This->ds3db_ds3db.flMaxDistance);
|
|
|
|
*lpfMaxDistance = This->ds3db_ds3db.flMaxDistance;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetMinDistance(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE *lpfMinDistance)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Min Distance = %f\n", This->ds3db_ds3db.flMinDistance);
|
|
|
|
*lpfMinDistance = This->ds3db_ds3db.flMinDistance;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetMode(IDirectSound3DBuffer *iface,
|
|
|
|
DWORD *lpdwMode)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Mode = %d\n", This->ds3db_ds3db.dwMode);
|
|
|
|
*lpdwMode = This->ds3db_ds3db.dwMode;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetPosition(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVECTOR *lpvPosition)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Position vector = (%f,%f,%f)\n", This->ds3db_ds3db.vPosition.x,
|
|
|
|
This->ds3db_ds3db.vPosition.y, This->ds3db_ds3db.vPosition.z);
|
|
|
|
*lpvPosition = This->ds3db_ds3db.vPosition;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_GetVelocity(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVECTOR *lpvVelocity)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->ds3db_ds3db.vVelocity.x,
|
|
|
|
This->ds3db_ds3db.vVelocity.y, This->ds3db_ds3db.vVelocity.z);
|
|
|
|
*lpvVelocity = This->ds3db_ds3db.vVelocity;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetAllParameters(IDirectSound3DBuffer *iface,
|
|
|
|
const DS3DBUFFER *lpcDs3dBuffer, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
2003-06-28 00:22:15 +02:00
|
|
|
DWORD status = DSERR_INVALIDPARAM;
|
2012-01-19 01:18:30 +01:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p,%x)\n",iface,lpcDs3dBuffer,dwApply);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
if (lpcDs3dBuffer == NULL) {
|
|
|
|
WARN("invalid parameter: lpcDs3dBuffer == NULL\n");
|
|
|
|
return status;
|
2002-12-13 01:31:06 +01:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
if (lpcDs3dBuffer->dwSize != sizeof(DS3DBUFFER)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: lpcDs3dBuffer->dwSize = %d\n", lpcDs3dBuffer->dwSize);
|
2003-06-28 00:22:15 +02:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: all parameters; dwApply = %d\n", dwApply);
|
2012-01-19 01:18:30 +01:00
|
|
|
This->ds3db_ds3db = *lpcDs3dBuffer;
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2003-09-02 02:56:14 +02:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
DSOUND_Mix3DBuffer(This);
|
2003-09-02 02:56:14 +02:00
|
|
|
}
|
2012-01-19 01:18:30 +01:00
|
|
|
This->ds3db_need_recalc = TRUE;
|
2003-09-02 02:56:14 +02:00
|
|
|
status = DS_OK;
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
return status;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeAngles(IDirectSound3DBuffer *iface,
|
|
|
|
DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: Inside Cone Angle = %d; Outside Cone Angle = %d; dwApply = %d\n",
|
|
|
|
dwInsideConeAngle, dwOutsideConeAngle, dwApply);
|
|
|
|
This->ds3db_ds3db.dwInsideConeAngle = dwInsideConeAngle;
|
|
|
|
This->ds3db_ds3db.dwOutsideConeAngle = dwOutsideConeAngle;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOrientation(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
|
|
|
|
This->ds3db_ds3db.vConeOrientation.x = x;
|
|
|
|
This->ds3db_ds3db.vConeOrientation.y = y;
|
|
|
|
This->ds3db_ds3db.vConeOrientation.z = z;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOutsideVolume(IDirectSound3DBuffer *iface,
|
|
|
|
LONG lConeOutsideVolume, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: ConeOutsideVolume = %d; dwApply = %d\n", lConeOutsideVolume, dwApply);
|
|
|
|
This->ds3db_ds3db.lConeOutsideVolume = lConeOutsideVolume;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetMaxDistance(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE fMaxDistance, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: MaxDistance = %f; dwApply = %d\n", fMaxDistance, dwApply);
|
|
|
|
This->ds3db_ds3db.flMaxDistance = fMaxDistance;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetMinDistance(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE fMinDistance, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: MinDistance = %f; dwApply = %d\n", fMinDistance, dwApply);
|
|
|
|
This->ds3db_ds3db.flMinDistance = fMinDistance;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetMode(IDirectSound3DBuffer *iface, DWORD dwMode,
|
|
|
|
DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: Mode = %d; dwApply = %d\n", dwMode, dwApply);
|
|
|
|
This->ds3db_ds3db.dwMode = dwMode;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetPosition(IDirectSound3DBuffer *iface, D3DVALUE x,
|
|
|
|
D3DVALUE y, D3DVALUE z, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
|
|
|
|
This->ds3db_ds3db.vPosition.x = x;
|
|
|
|
This->ds3db_ds3db.vPosition.y = y;
|
|
|
|
This->ds3db_ds3db.vPosition.z = z;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:13:04 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DBufferImpl_SetVelocity(IDirectSound3DBuffer *iface,
|
|
|
|
D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-19 01:18:30 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DBuffer(iface);
|
|
|
|
|
|
|
|
TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
|
|
|
|
This->ds3db_ds3db.vVelocity.x = x;
|
|
|
|
This->ds3db_ds3db.vVelocity.y = y;
|
|
|
|
This->ds3db_ds3db.vVelocity.z = z;
|
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
|
|
|
This->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Mix3DBuffer(This);
|
|
|
|
}
|
|
|
|
This->ds3db_need_recalc = TRUE;
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-19 01:18:30 +01:00
|
|
|
const IDirectSound3DBufferVtbl ds3dbvt =
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSound3DBufferImpl_QueryInterface,
|
|
|
|
IDirectSound3DBufferImpl_AddRef,
|
|
|
|
IDirectSound3DBufferImpl_Release,
|
|
|
|
/* IDirectSound3DBuffer methods */
|
|
|
|
IDirectSound3DBufferImpl_GetAllParameters,
|
|
|
|
IDirectSound3DBufferImpl_GetConeAngles,
|
|
|
|
IDirectSound3DBufferImpl_GetConeOrientation,
|
|
|
|
IDirectSound3DBufferImpl_GetConeOutsideVolume,
|
|
|
|
IDirectSound3DBufferImpl_GetMaxDistance,
|
|
|
|
IDirectSound3DBufferImpl_GetMinDistance,
|
|
|
|
IDirectSound3DBufferImpl_GetMode,
|
|
|
|
IDirectSound3DBufferImpl_GetPosition,
|
|
|
|
IDirectSound3DBufferImpl_GetVelocity,
|
|
|
|
IDirectSound3DBufferImpl_SetAllParameters,
|
|
|
|
IDirectSound3DBufferImpl_SetConeAngles,
|
|
|
|
IDirectSound3DBufferImpl_SetConeOrientation,
|
|
|
|
IDirectSound3DBufferImpl_SetConeOutsideVolume,
|
|
|
|
IDirectSound3DBufferImpl_SetMaxDistance,
|
|
|
|
IDirectSound3DBufferImpl_SetMinDistance,
|
|
|
|
IDirectSound3DBufferImpl_SetMode,
|
|
|
|
IDirectSound3DBufferImpl_SetPosition,
|
|
|
|
IDirectSound3DBufferImpl_SetVelocity,
|
|
|
|
};
|
|
|
|
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSound3DListener
|
|
|
|
*/
|
2012-01-16 00:13:31 +01:00
|
|
|
static inline IDirectSoundBufferImpl *impl_from_IDirectSound3DListener(IDirectSound3DListener *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
return CONTAINING_RECORD(iface, IDirectSoundBufferImpl, IDirectSound3DListener_iface);
|
|
|
|
}
|
2003-08-07 00:57:24 +02:00
|
|
|
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
/* IUnknown methods */
|
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(IDirectSound3DListener *iface,
|
|
|
|
REFIID riid, void **ppobj)
|
|
|
|
{
|
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
return IDirectSoundBuffer_QueryInterface(&This->IDirectSoundBuffer8_iface, riid, ppobj);
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(IDirectSound3DListener *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref3D);
|
2011-08-31 01:13:33 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2011-08-31 01:13:33 +02:00
|
|
|
|
|
|
|
if(ref == 1)
|
2012-01-16 00:13:31 +01:00
|
|
|
InterlockedIncrement(&This->numIfaces);
|
2011-08-31 01:13:33 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static ULONG WINAPI IDirectSound3DListenerImpl_Release(IDirectSound3DListener *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
2012-05-09 15:48:56 +02:00
|
|
|
ULONG ref;
|
2012-01-16 00:13:31 +01:00
|
|
|
|
2012-05-09 15:48:56 +02:00
|
|
|
ref = capped_refcount_dec(&This->ref3D);
|
|
|
|
if(!ref)
|
|
|
|
capped_refcount_dec(&This->numIfaces);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2012-05-09 15:48:56 +02:00
|
|
|
TRACE("(%p) ref is now %d\n", This, ref);
|
2012-01-16 00:13:31 +01:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDirectSound3DListener methods */
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(IDirectSound3DListener *iface,
|
|
|
|
DS3DLISTENER *lpDS3DL)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
TRACE("(%p,%p)\n",This,lpDS3DL);
|
|
|
|
|
|
|
|
if (lpDS3DL == NULL) {
|
2003-07-02 06:37:26 +02:00
|
|
|
WARN("invalid parameter: lpDS3DL == NULL\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDS3DL->dwSize < sizeof(*lpDS3DL)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: lpDS3DL->dwSize = %d\n",lpDS3DL->dwSize);
|
2003-06-28 00:22:15 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2002-12-13 00:01:05 +01:00
|
|
|
TRACE("returning: all parameters\n");
|
2006-01-06 12:35:20 +01:00
|
|
|
*lpDS3DL = This->device->ds3dl;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE *lpfDistanceFactor)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("returning: Distance Factor = %f\n", This->device->ds3dl.flDistanceFactor);
|
|
|
|
*lpfDistanceFactor = This->device->ds3dl.flDistanceFactor;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE *lpfDopplerFactor)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("returning: Doppler Factor = %f\n", This->device->ds3dl.flDopplerFactor);
|
|
|
|
*lpfDopplerFactor = This->device->ds3dl.flDopplerFactor;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(IDirectSound3DListener *iface,
|
|
|
|
D3DVECTOR *lpvOrientFront, D3DVECTOR *lpvOrientTop)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2007-01-09 00:39:23 +01:00
|
|
|
TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->device->ds3dl.vOrientFront.x,
|
|
|
|
This->device->ds3dl.vOrientFront.y, This->device->ds3dl.vOrientFront.z, This->device->ds3dl.vOrientTop.x, This->device->ds3dl.vOrientTop.y,
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.vOrientTop.z);
|
|
|
|
*lpvOrientFront = This->device->ds3dl.vOrientFront;
|
|
|
|
*lpvOrientTop = This->device->ds3dl.vOrientTop;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(IDirectSound3DListener *iface,
|
|
|
|
D3DVECTOR *lpvPosition)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("returning: Position vector = (%f,%f,%f)\n", This->device->ds3dl.vPosition.x, This->device->ds3dl.vPosition.y, This->device->ds3dl.vPosition.z);
|
|
|
|
*lpvPosition = This->device->ds3dl.vPosition;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE *lpfRolloffFactor)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("returning: RolloffFactor = %f\n", This->device->ds3dl.flRolloffFactor);
|
|
|
|
*lpfRolloffFactor = This->device->ds3dl.flRolloffFactor;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(IDirectSound3DListener *iface,
|
|
|
|
D3DVECTOR *lpvVelocity)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->device->ds3dl.vVelocity.x, This->device->ds3dl.vVelocity.y, This->device->ds3dl.vVelocity.z);
|
|
|
|
*lpvVelocity = This->device->ds3dl.vVelocity;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(IDirectSound3DListener *iface,
|
|
|
|
const DS3DLISTENER *lpcDS3DL, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: all parameters; dwApply = %d\n", dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl = *lpcDS3DL;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE fDistanceFactor, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: Distance Factor = %f; dwApply = %d\n", fDistanceFactor, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.flDistanceFactor = fDistanceFactor;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE fDopplerFactor, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: Doppler Factor = %f; dwApply = %d\n", fDopplerFactor, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.flDopplerFactor = fDopplerFactor;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, D3DVALUE xTop, D3DVALUE yTop,
|
|
|
|
D3DVALUE zTop, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2007-01-09 00:39:23 +01:00
|
|
|
TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %d\n",
|
2002-12-14 00:20:58 +01:00
|
|
|
xFront, yFront, zFront, xTop, yTop, zTop, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.vOrientFront.x = xFront;
|
|
|
|
This->device->ds3dl.vOrientFront.y = yFront;
|
|
|
|
This->device->ds3dl.vOrientFront.z = zFront;
|
|
|
|
This->device->ds3dl.vOrientTop.x = xTop;
|
|
|
|
This->device->ds3dl.vOrientTop.y = yTop;
|
|
|
|
This->device->ds3dl.vOrientTop.z = zTop;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.vPosition.x = x;
|
|
|
|
This->device->ds3dl.vPosition.y = y;
|
|
|
|
This->device->ds3dl.vPosition.z = z;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE fRolloffFactor, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: Rolloff Factor = %f; dwApply = %d\n", fRolloffFactor, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.flRolloffFactor = fRolloffFactor;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(IDirectSound3DListener *iface,
|
|
|
|
D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl.vVelocity.x = x;
|
|
|
|
This->device->ds3dl.vVelocity.y = y;
|
|
|
|
This->device->ds3dl.vVelocity.z = z;
|
2002-12-14 00:20:58 +01:00
|
|
|
if (dwApply == DS3D_IMMEDIATE)
|
|
|
|
{
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = FALSE;
|
2003-01-04 02:22:51 +01:00
|
|
|
DSOUND_ChangeListener(This);
|
2002-12-14 00:20:58 +01:00
|
|
|
}
|
2006-01-06 12:35:20 +01:00
|
|
|
This->device->ds3dl_need_recalc = TRUE;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
static HRESULT WINAPI IDirectSound3DListenerImpl_CommitDeferredSettings(IDirectSound3DListener *iface)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2012-01-16 00:13:31 +01:00
|
|
|
IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
|
|
|
|
|
2003-01-04 02:22:51 +01:00
|
|
|
TRACE("\n");
|
|
|
|
DSOUND_ChangeListener(This);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-16 00:13:31 +01:00
|
|
|
const IDirectSound3DListenerVtbl ds3dlvt =
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
IDirectSound3DListenerImpl_QueryInterface,
|
|
|
|
IDirectSound3DListenerImpl_AddRef,
|
|
|
|
IDirectSound3DListenerImpl_Release,
|
|
|
|
/* IDirectSound3DListener methods */
|
|
|
|
IDirectSound3DListenerImpl_GetAllParameter,
|
|
|
|
IDirectSound3DListenerImpl_GetDistanceFactor,
|
|
|
|
IDirectSound3DListenerImpl_GetDopplerFactor,
|
|
|
|
IDirectSound3DListenerImpl_GetOrientation,
|
|
|
|
IDirectSound3DListenerImpl_GetPosition,
|
|
|
|
IDirectSound3DListenerImpl_GetRolloffFactor,
|
|
|
|
IDirectSound3DListenerImpl_GetVelocity,
|
|
|
|
IDirectSound3DListenerImpl_SetAllParameters,
|
|
|
|
IDirectSound3DListenerImpl_SetDistanceFactor,
|
|
|
|
IDirectSound3DListenerImpl_SetDopplerFactor,
|
|
|
|
IDirectSound3DListenerImpl_SetOrientation,
|
|
|
|
IDirectSound3DListenerImpl_SetPosition,
|
|
|
|
IDirectSound3DListenerImpl_SetRolloffFactor,
|
|
|
|
IDirectSound3DListenerImpl_SetVelocity,
|
|
|
|
IDirectSound3DListenerImpl_CommitDeferredSettings,
|
|
|
|
};
|