mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-25 10:13:42 +00:00
Add define to enable/disable external 3d audio simulation
This commit is contained in:
parent
2eb0390dc9
commit
6c2d179aad
4 changed files with 123 additions and 2 deletions
|
@ -1329,6 +1329,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
|
|||
AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1), SFX_BANK_0, 2, TRUE);
|
||||
} else {
|
||||
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
||||
#ifndef EXTERNAL_3D_SOUND
|
||||
m_sQueueSample.m_nOffset = ComputePan(m_sQueueSample.m_fDistance, &pos);
|
||||
#endif
|
||||
if (bAccelSampleStopped) {
|
||||
if (CurrentPretendGear != 1 || currentGear != 2) {
|
||||
gearNr = currentGear - 1;
|
||||
|
@ -1356,9 +1359,15 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CAutomobile *
|
|||
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 85);
|
||||
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
|
||||
SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.f, 12.5f);
|
||||
#else
|
||||
|
||||
SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(85, 50.0f, m_sQueueSample.m_fDistance));
|
||||
SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nOffset);
|
||||
#endif
|
||||
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
|
||||
if (engineSoundType == SFX_BANK_TRUCK)
|
||||
freq /= 2;
|
||||
|
|
|
@ -56,11 +56,16 @@ cAudioManager::Initialise()
|
|||
PreInitialiseGameSpecificSetup();
|
||||
m_bIsInitialised = SampleManager.Initialise();
|
||||
if (m_bIsInitialised) {
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
|
||||
if (m_nActiveSamples <= 1) {
|
||||
Terminate();
|
||||
} else {
|
||||
--m_nActiveSamples;
|
||||
#else
|
||||
{
|
||||
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
||||
#endif
|
||||
PostInitialiseGameSpecificSetup();
|
||||
InitialisePoliceRadioZones();
|
||||
InitialisePoliceRadio();
|
||||
|
@ -375,9 +380,11 @@ cAudioManager::SetCurrent3DProvider(uint8 which)
|
|||
ClearActiveSamples();
|
||||
int8 current = SampleManager.SetCurrent3DProvider(which);
|
||||
if (current > 0) {
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
|
||||
if (m_nActiveSamples > 1)
|
||||
--m_nActiveSamples;
|
||||
#endif
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
@ -786,10 +793,12 @@ cAudioManager::ProcessActiveQueues()
|
|||
uint32 v28;
|
||||
uint32 v29;
|
||||
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
float x;
|
||||
float usedX;
|
||||
float usedY;
|
||||
float usedZ;
|
||||
#endif
|
||||
|
||||
uint8 vol;
|
||||
uint8 emittingVol;
|
||||
|
@ -825,13 +834,26 @@ cAudioManager::ProcessActiveQueues()
|
|||
sample.m_nVolumeChange = -1;
|
||||
if (!sample.m_bReleasingSoundFlag) {
|
||||
if (sample.m_bIs2D) {
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
if (field_4) {
|
||||
emittingVol = 2 * Min(63, sample.m_nEmittingVolume);
|
||||
} else {
|
||||
emittingVol = sample.m_nEmittingVolume;
|
||||
}
|
||||
#else
|
||||
if (field_4) {
|
||||
emittingVol = 2 * Min(63, sample.m_nVolume);
|
||||
} else {
|
||||
emittingVol = sample.m_nVolume;
|
||||
}
|
||||
#endif
|
||||
SampleManager.SetChannelFrequency(j, sample.m_nFrequency);
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
SampleManager.SetChannelEmittingVolume(j, emittingVol);
|
||||
#else
|
||||
SampleManager.SetChannelPan(j, sample.m_nOffset);
|
||||
SampleManager.SetChannelVolume(j, sample.m_nVolume);
|
||||
#endif
|
||||
} else {
|
||||
m_asActiveSamples[j].m_fDistance = sample.m_fDistance;
|
||||
position2 = sample.m_fDistance;
|
||||
|
@ -852,6 +874,7 @@ cAudioManager::ProcessActiveQueues()
|
|||
SampleManager.SetChannelFrequency(j, freq);
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
|
||||
if (sample.m_nEmittingVolume <= m_asActiveSamples[j].m_nEmittingVolume) {
|
||||
vol = Max(m_asActiveSamples[j].m_nEmittingVolume - 10, sample.m_nEmittingVolume);
|
||||
|
@ -868,9 +891,32 @@ cAudioManager::ProcessActiveQueues()
|
|||
SampleManager.SetChannelEmittingVolume(j, emittingVol);
|
||||
m_asActiveSamples[j].m_nEmittingVolume = vol;
|
||||
}
|
||||
#else
|
||||
if (sample.m_nVolume != m_asActiveSamples[j].m_nVolume) {
|
||||
if (sample.m_nVolume <= m_asActiveSamples[j].m_nVolume) {
|
||||
vol = Max(m_asActiveSamples[j].m_nVolume - 10, sample.m_nVolume);
|
||||
} else {
|
||||
vol = Min(m_asActiveSamples[j].m_nVolume + 10, sample.m_nVolume);
|
||||
}
|
||||
m_asActiveSamples[j].m_nVolume = vol;
|
||||
|
||||
uint8 emittingVol;
|
||||
if (field_4) {
|
||||
emittingVol = 2 * Min(63, vol);
|
||||
} else {
|
||||
emittingVol = vol;
|
||||
}
|
||||
SampleManager.SetChannelVolume(j, emittingVol);
|
||||
}
|
||||
#endif
|
||||
TranslateEntity(&sample.m_vecPos, &position);
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z);
|
||||
SampleManager.SetChannel3DDistances(j, sample.m_fSoundIntensity, 0.25f * sample.m_fSoundIntensity);
|
||||
#else
|
||||
sample.m_nOffset = ComputePan(sample.m_fDistance, &position);
|
||||
SampleManager.SetChannelPan(j, sample.m_nOffset);
|
||||
#endif
|
||||
}
|
||||
SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag);
|
||||
break;
|
||||
|
@ -905,19 +951,38 @@ cAudioManager::ProcessActiveQueues()
|
|||
sample.m_nReleasingVolumeDivider = v29 / v28 + 1;
|
||||
}
|
||||
memcpy(&m_asActiveSamples[j], &sample, sizeof(tSound));
|
||||
if (!m_asActiveSamples[j].m_bIs2D)
|
||||
if (!m_asActiveSamples[j].m_bIs2D) {
|
||||
TranslateEntity(&m_asActiveSamples[j].m_vecPos, &position);
|
||||
#ifndef EXTERNAL_3D_SOUND
|
||||
m_asActiveSamples[j].m_nOffset = ComputePan(m_asActiveSamples[j].m_fDistance, &position);
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
if (field_4) {
|
||||
emittingVol = 2 * Min(63, m_asActiveSamples[j].m_nEmittingVolume);
|
||||
} else {
|
||||
emittingVol = m_asActiveSamples[j].m_nEmittingVolume;
|
||||
}
|
||||
#else
|
||||
if (field_4) {
|
||||
emittingVol = 2 * Min(63, m_asActiveSamples[j].m_nVolume);
|
||||
} else {
|
||||
emittingVol = m_asActiveSamples[j].m_nVolume;
|
||||
}
|
||||
#endif
|
||||
if (SampleManager.InitialiseChannel(j, m_asActiveSamples[j].m_nSampleIndex, m_asActiveSamples[j].m_nBankIndex)) {
|
||||
SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
SampleManager.SetChannelEmittingVolume(j, emittingVol);
|
||||
#else
|
||||
SampleManager.SetChannelVolume(j, m_asActiveSamples[j].m_nVolume);
|
||||
SampleManager.SetChannelPan(j, m_asActiveSamples[j].m_nOffset);
|
||||
#endif
|
||||
SampleManager.SetChannelLoopPoints(j, m_asActiveSamples[j].m_nLoopStart, m_asActiveSamples[j].m_nLoopEnd);
|
||||
SampleManager.SetChannelLoopCount(j, m_asActiveSamples[j].m_nLoopCount);
|
||||
SampleManager.SetChannelReverbFlag(j, m_asActiveSamples[j].m_bReverbFlag);
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
if (m_asActiveSamples[j].m_bIs2D) {
|
||||
uint8 offset = m_asActiveSamples[j].m_nOffset;
|
||||
if (offset == 63) {
|
||||
|
@ -938,6 +1003,7 @@ cAudioManager::ProcessActiveQueues()
|
|||
}
|
||||
SampleManager.SetChannel3DPosition(j, usedX, usedY, usedZ);
|
||||
SampleManager.SetChannel3DDistances(j, m_asActiveSamples[j].m_fSoundIntensity, 0.25f * m_asActiveSamples[j].m_fSoundIntensity);
|
||||
#endif
|
||||
SampleManager.StartChannel(j);
|
||||
}
|
||||
m_asActiveSamples[j].m_bIsProcessed = TRUE;
|
||||
|
|
|
@ -100,9 +100,15 @@ enum
|
|||
|
||||
#define MAXPROVIDERS 64
|
||||
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
#define MAXCHANNELS (NUM_CHANNELS_GENERIC+1)
|
||||
#define MAXCHANNELS_SURROUND (MAXCHANNELS-4)
|
||||
#define MAX2DCHANNELS 1
|
||||
#else
|
||||
#define MAXCHANNELS 0
|
||||
#define MAXCHANNELS_SURROUND 0
|
||||
#define MAX2DCHANNELS NUM_CHANNELS
|
||||
#endif
|
||||
|
||||
#define MAX_STREAMS 2
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ S32 curprovider=-1;
|
|||
S32 usingEAX=0;
|
||||
S32 usingEAX3=0;
|
||||
HPROVIDER opened_provider=0;
|
||||
H3DSAMPLE opened_samples[MAXCHANNELS] = {0};
|
||||
H3DSAMPLE opened_samples[MAXCHANNELS ? MAXCHANNELS : 1] = {0};
|
||||
HSAMPLE opened_2dsamples[MAX2DCHANNELS] = {0};
|
||||
HDIGDRIVER DIG;
|
||||
S32 speaker_type=0;
|
||||
|
@ -1709,7 +1709,11 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1738,7 +1742,11 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1838,7 +1846,11 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
nChannelVolume[nChannel] = vol;
|
||||
|
||||
|
@ -1866,7 +1878,11 @@ cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan)
|
|||
{
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
#ifndef FIX_BUGS
|
||||
if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG
|
||||
|
@ -1887,7 +1903,11 @@ cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1913,7 +1933,11 @@ cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 n
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1939,7 +1963,11 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1965,7 +1993,11 @@ cSampleManager::GetChannelUsedFlag(uint32 nChannel)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -1996,7 +2028,11 @@ cSampleManager::StartChannel(uint32 nChannel)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
@ -2022,7 +2058,11 @@ cSampleManager::StopChannel(uint32 nChannel)
|
|||
|
||||
switch ( nChannel )
|
||||
{
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
case CHANNEL_POLICE_RADIO:
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
{
|
||||
b2d = TRUE;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue