本文整理汇总了C++中LPDIRECTSOUND3DLISTENER类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUND3DLISTENER类的具体用法?C++ LPDIRECTSOUND3DLISTENER怎么用?C++ LPDIRECTSOUND3DLISTENER使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTSOUND3DLISTENER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ds_SetAllListenerParameters
//-----------------------------------------------------------------------------
// Установка всех параметров слушателя
// на входе : listener - указатель на интерфейс слушателя
// data - указатель на структуру в которой содержатся
// параметры слушателя
// на выходе : успешность установки параметров слушателя
//-----------------------------------------------------------------------------
int ds_SetAllListenerParameters(LPDIRECTSOUND3DLISTENER listener,
LPDS3DLISTENER data, DWORD def)
{
int ret = false;
// проверка наличия слушателя
if (!listener)
return ret;
// установка позиции
ret = (listener->SetPosition(data->vPosition.x,
data->vPosition.y,
data->vPosition.z,
def) == DS_OK) ?
true :
false;
// установка скорости слушателя
if (ret)
ret = (listener->SetVelocity(data->vVelocity.x,
data->vVelocity.y,
data->vVelocity.z,
def) == DS_OK) ?
true :
false;
// установка ориентации
if (ret)
ret = (listener->SetOrientation(data->vOrientFront.x,
data->vOrientFront.y,
data->vOrientFront.z,
data->vOrientTop.x,
data->vOrientTop.y,
data->vOrientTop.z,
def) == DS_OK) ?
true :
false;
// установка дистанции
if (ret)
ret = (listener->SetDistanceFactor(data->flDistanceFactor, def) ==
DS_OK) ?
true :
false;
// установка фактора удаления
if (ret)
ret = (listener->SetRolloffFactor(data->flRolloffFactor, def) == DS_OK) ?
true :
false;
// установка эффекта допплера
if (ret)
ret = (listener->SetDopplerFactor(data->flDopplerFactor, def) == DS_OK) ?
true :
false;
return ret;
}
示例2: ds_GetAllListenerParameters
//-----------------------------------------------------------------------------
// Получение всех параметров слушателя
// на входе : listener - указатель на интерфейс слушателя
// data - указатель на структуру в которую нужно поместить
// параметры слушателя
// на выходе : успешность получения параметров слушателя
//-----------------------------------------------------------------------------
int ds_GetAllListenerParameters(LPDIRECTSOUND3DLISTENER listener,
LPDS3DLISTENER data)
{
// проверка наличия слушателя
if (!listener)
return false;
// пропишем размер структуры
data->dwSize = sizeof(DS3DLISTENER);
// получение параметров слушателя
if (listener->GetAllParameters(data) == DS_OK)
return true;
return false;
}
示例3: ds_ReleaseListener
//-----------------------------------------------------------------------------
// Освобождение интерфейса слушателя
// на входе : listener - указатель на интерфейс слушателя
// на выходе : *
//-----------------------------------------------------------------------------
void ds_ReleaseListener(LPDIRECTSOUND3DLISTENER listener)
{
if (listener)
listener->Release();
}
示例4: DS_Listenerv
//===========================================================================
// DS_Listenerv
// Call SFXLP_UPDATE at the end of every channel update.
//===========================================================================
void DS_Listenerv(int property, float *values)
{
if(!dsListener) return;
switch(property)
{
case SFXLP_POSITION:
dsListener->SetPosition(values[VX], values[VZ], values[VY],
DS3D_DEFERRED);
break;
case SFXLP_VELOCITY:
dsListener->SetVelocity(values[VX], values[VZ], values[VY],
DS3D_DEFERRED);
break;
case SFXLP_ORIENTATION:
ListenerOrientation(values[VX]/180*PI, values[VY]/180*PI);
break;
case SFXLP_REVERB:
ListenerEnvironment(values);
break;
default:
DS_Listener(property, 0);
}
}
示例5: ds3d_close_listener
// ---------------------------------------------------------------------------------------
// ds3d_close_listener()
//
//
void ds3d_close_listener()
{
if ( pDS3D_listener != NULL ) {
pDS3D_listener->Release();
pDS3D_listener = NULL;
}
}
示例6: Release
static void Release(void)
{
if (!g_lpDSDevice)
return;
if ( g_lpPrimaryBuffer!=NULL )
{
ULONG status;
ChannelFlushAll(0);
g_lpPrimaryBuffer->GetStatus(&status);
if ( (status&DSBSTATUS_PLAYING)==DSBSTATUS_PLAYING )
g_lpPrimaryBuffer->Stop();
if (g_lpDS3DListener)
g_lpDS3DListener->Release();
g_lpPrimaryBuffer->Release();
g_lpPrimaryBuffer = NULL;
}
if (V3XA.p_driverList)
{
array_free(V3XA.p_driverList);
V3XA.p_driverList = NULL;
}
}
示例7: Render
static void RLXAPI Render(void)
{
HRESULT hr;
if (g_lpDS3DListener)
{
hr = SYS_DXTRACE(g_lpDS3DListener->CommitDeferredSettings());
}
}
示例8: DriverReleaseA
static void DriverReleaseA(void)
{
if (g_lpDS3DListener)
g_lpDS3DListener->Release();
if (g_lpPrimaryBuffer)
g_lpPrimaryBuffer->Release();
}
示例9: DS_Listener
//===========================================================================
// DS_Listener
// SFXLP_UNITS_PER_METER
// SFXLP_DOPPLER
// SFXLP_UPDATE
//===========================================================================
void DS_Listener(int property, float value)
{
if(!dsListener) return;
switch(property)
{
case SFXLP_UPDATE:
// Commit any deferred settings.
dsListener->CommitDeferredSettings();
EAXCommitDeferred();
break;
case SFXLP_UNITS_PER_METER:
dsListener->SetDistanceFactor(1/value, DS3D_IMMEDIATE);
break;
case SFXLP_DOPPLER:
dsListener->SetDopplerFactor(value, DS3D_IMMEDIATE);
break;
}
}
示例10: UserSetParms
static void RLXAPI UserSetParms(V3XMATRIX *lpMAT, V3XVECTOR *lpVEL,
float*lpDistanceF, float*lpDopplerF, float*lpRolloffF)
{
HRESULT hr;
if (!g_lpDS3DListener)
return;
if (lpMAT)
{
V3XVECTOR *ps = &lpMAT->v.Pos;
hr = g_lpDS3DListener->SetPosition(ps->x, ps->y, ps->z, DS3D_DEFMODE);
g_lpDS3DListener->SetOrientation(
lpMAT->v.K.x, lpMAT->v.K.y, lpMAT->v.K.z, // 3D engine use a other orientation (right hand)
lpMAT->v.J.x, lpMAT->v.J.y, lpMAT->v.J.z,
DS3D_DEFMODE);
}
if (lpVEL)
g_lpDS3DListener->SetVelocity(lpVEL->x, lpVEL->y, lpVEL->z, DS3D_DEFMODE);
if (lpDistanceF)
g_lpDS3DListener->SetDistanceFactor(*lpDistanceF, DS3D_DEFMODE);
if (lpDopplerF)
g_lpDS3DListener->SetDopplerFactor( *lpDopplerF, DS3D_DEFMODE);
if (lpRolloffF)
g_lpDS3DListener->SetRolloffFactor( *lpRolloffF, DS3D_DEFMODE);
}
示例11: DS_Shutdown
//===========================================================================
// DS_Shutdown
//===========================================================================
void DS_Shutdown(void)
{
if(!initOk) return;
if(eaxListener) eaxListener->Release();
if(dsListener) dsListener->Release();
if(primary) primary->Release();
if(dsound) dsound->Release();
eaxListener = NULL;
dsListener = NULL;
primary = NULL;
dsound = NULL;
initOk = false;
}
示例12: ListenerOrientation
//===========================================================================
// DS_DSoundListenerOrientation
// Parameters are in radians.
// Example front vectors:
// Yaw 0:(0,0,1), pi/2:(-1,0,0)
//===========================================================================
void ListenerOrientation(float yaw, float pitch)
{
float front[3], up[3];
if(!dsListener) return;
front[VX] = cos(yaw) * cos(pitch);
front[VZ] = sin(yaw) * cos(pitch);
front[VY] = sin(pitch);
up[VX] = -cos(yaw) * sin(pitch);
up[VZ] = -sin(yaw) * sin(pitch);
up[VY] = cos(pitch);
dsListener->SetOrientation(front[VX], front[VY], front[VZ],
up[VX], up[VY], up[VZ], DS3D_DEFERRED);
}
示例13: Initialize
static int Initialize(void *hwnd)
{
DSBUFFERDESC primaryDesc;
if (!g_lpDSDevice) return TRUE;
sysMemZero(&primaryDesc, sizeof(DSBUFFERDESC));
primaryDesc.dwSize = sizeof(DSBUFFERDESC);
primaryDesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if (RLX.Audio.Config & RLXAUDIO_Use3D)
primaryDesc.dwFlags|= DSBCAPS_CTRL3D;
if (SYS_DXTRACE(g_lpDSDevice->SetCooperativeLevel((HWND)hwnd, DSSCL_EXCLUSIVE)) != DS_OK)
return -1;
if (SYS_DXTRACE(g_lpDSDevice->CreateSoundBuffer(&primaryDesc, &g_lpPrimaryBuffer, NULL))!=DS_OK )
return 0;
else
{
HRESULT hr;
sysMemZero(&g_cDSPCMOutFormat, sizeof(WAVEFORMATEX));
g_cDSPCMOutFormat.wFormatTag = WAVE_FORMAT_PCM;
g_cDSPCMOutFormat.wBitsPerSample = 16;
g_cDSPCMOutFormat.nChannels = 2;
g_cDSPCMOutFormat.nSamplesPerSec = 44100;
g_cDSPCMOutFormat.nBlockAlign = (uint16_t)(g_cDSPCMOutFormat.nChannels * (g_cDSPCMOutFormat.wBitsPerSample>>3));
g_cDSPCMOutFormat.nAvgBytesPerSec = (uint32_t)g_cDSPCMOutFormat.nBlockAlign * (uint32_t)g_cDSPCMOutFormat.nSamplesPerSec;
hr = g_lpPrimaryBuffer->SetFormat(&g_cDSPCMOutFormat);
if ( hr != DS_OK )
FindAlternateSampleFormat();
if (RLX.Audio.Config & RLXAUDIO_Use3D)
{
hr = SYS_DXTRACE(g_lpPrimaryBuffer->QueryInterface(IID_IDirectSound3DListener, (void**)&g_lpDS3DListener));
if (hr== DS_OK)
hr = g_lpDS3DListener->SetAllParameters(&Listener3dProps, DS3D_IMMEDIATE);
}
}
return 0; // no problemo.
}
示例14: ds3d_update_listener
// ---------------------------------------------------------------------------------------
// ds3d_update_listener()
//
// returns: 0 => success
// -1 => failure
//
int ds3d_update_listener(vector *pos, vector *vel, matrix *orient)
{
HRESULT hr;
if (DS3D_inited == FALSE)
return 0;
if ( pDS3D_listener == NULL )
return -1;
// set the listener position
if ( pos != NULL ) {
hr = pDS3D_listener->SetPosition(pos->x, pos->y, pos->z, DS3D_DEFERRED);
}
// set the listener veclocity
if ( vel != NULL ) {
hr = pDS3D_listener->SetVelocity(vel->x, vel->y, vel->z, DS3D_DEFERRED);
}
if ( orient != NULL ) {
hr = pDS3D_listener->SetOrientation( orient->fvec.x, orient->fvec.y, orient->fvec.z,
orient->uvec.x, orient->uvec.y, orient->uvec.z,
DS3D_DEFERRED );
}
float rolloff_factor = 1.0f;
if (ds_using_a3d() == true) {
rolloff_factor = 3.0f; // A3D rolloff
} else {
rolloff_factor = 3.0f; // EAX rolloff
}
hr = pDS3D_listener->SetRolloffFactor( rolloff_factor, DS3D_DEFERRED );
hr = pDS3D_listener->SetDopplerFactor( 1.0f, DS3D_DEFERRED );
hr = pDS3D_listener->CommitDeferredSettings();
if ( hr != DS_OK ) {
nprintf(("SOUND","Error in pDS3D_listener->CommitDeferredSettings(): %s\n", get_DSERR_text(hr) ));
return -1;
}
return 0;
}
示例15: Set3DParameters
//-----------------------------------------------------------------------------
// Name: Set3DParameters()
// Desc: Set the 3D buffer parameters
//-----------------------------------------------------------------------------
VOID Set3DParameters( FLOAT fDopplerFactor, FLOAT fRolloffFactor,
FLOAT fMinDistance, FLOAT fMaxDistance )
{
// Every change to 3-D sound buffer and listener settings causes
// DirectSound to remix, at the expense of CPU cycles.
// To minimize the performance impact of changing 3-D settings,
// use the DS3D_DEFERRED flag in the dwApply parameter of any of
// the IDirectSound3DListener or IDirectSound3DBuffer methods that
// change 3-D settings. Then call the IDirectSound3DListener::CommitDeferredSettings
// method to execute all of the deferred commands at once.
DWORD dwApplyFlag = ( g_bDeferSettings ) ? DS3D_DEFERRED : DS3D_IMMEDIATE;
g_dsListenerParams.flDopplerFactor = fDopplerFactor;
g_dsListenerParams.flRolloffFactor = fRolloffFactor;
if( g_pDSListener )
g_pDSListener->SetAllParameters( &g_dsListenerParams, dwApplyFlag );
g_dsBufferParams.flMinDistance = fMinDistance;
g_dsBufferParams.flMaxDistance = fMaxDistance;
if( g_pDS3DBuffer )
g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, dwApplyFlag );
}