mirror of
https://github.com/GTAmodding/re3.git
synced 2025-07-17 00:04:09 +00:00
Handle stereo panning in OAL manually for streams
This commit is contained in:
parent
601f77b5c8
commit
7adac51152
3 changed files with 195 additions and 70 deletions
|
@ -102,7 +102,7 @@ CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS];
|
|||
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
|
||||
|
||||
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS];
|
||||
ALuint ALStreamSources[MAX_STREAMS];
|
||||
ALuint ALStreamSources[MAX_STREAMS*2];
|
||||
ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS];
|
||||
|
||||
struct tMP3Entry
|
||||
|
@ -245,9 +245,9 @@ release_existing()
|
|||
if (stream)
|
||||
stream->ProviderTerm();
|
||||
|
||||
alDeleteSources(1, &ALStreamSources[i]);
|
||||
alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]);
|
||||
}
|
||||
alDeleteSources(MAX_STREAMS*2, ALStreamSources);
|
||||
|
||||
CChannel::DestroyChannels();
|
||||
|
||||
|
@ -287,7 +287,10 @@ set_new_provider(int index)
|
|||
//TODO:
|
||||
_maxSamples = MAXCHANNELS;
|
||||
|
||||
ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0};
|
||||
ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,
|
||||
ALC_MONO_SOURCES, MAX_STREAMS * 2 + MAXCHANNELS,
|
||||
0,
|
||||
};
|
||||
|
||||
ALDevice = alcOpenDevice(providers[index].id);
|
||||
ASSERT(ALDevice != NULL);
|
||||
|
@ -319,11 +322,17 @@ set_new_provider(int index)
|
|||
alGenAuxiliaryEffectSlots(1, &ALEffectSlot);
|
||||
alGenEffects(1, &ALEffect);
|
||||
}
|
||||
|
||||
|
||||
alGenSources(MAX_STREAMS*2, ALStreamSources);
|
||||
for ( int32 i = 0; i < MAX_STREAMS; i++ )
|
||||
{
|
||||
alGenSources(1, &ALStreamSources[i]);
|
||||
alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]);
|
||||
alSourcei(ALStreamSources[i*2], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(ALStreamSources[i*2], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(ALStreamSources[i*2], AL_GAIN, 1.0f);
|
||||
alSourcei(ALStreamSources[i*2+1], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(ALStreamSources[i*2+1], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(ALStreamSources[i*2+1], AL_GAIN, 1.0f);
|
||||
|
||||
CStream *stream = aStream[i];
|
||||
if (stream)
|
||||
|
@ -603,7 +612,7 @@ _FindMP3s(void)
|
|||
} else
|
||||
bShortcut = false;
|
||||
|
||||
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
|
||||
aStream[0] = new CStream(filepath, &ALStreamSources[0], ALStreamBuffers[0]);
|
||||
|
||||
if (aStream[0] && aStream[0]->IsOpened())
|
||||
{
|
||||
|
@ -677,7 +686,7 @@ _FindMP3s(void)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
|
||||
aStream[0] = new CStream(filepath, &ALStreamSources[0], ALStreamBuffers[0]);
|
||||
|
||||
if (aStream[0] && aStream[0]->IsOpened())
|
||||
{
|
||||
|
@ -737,7 +746,7 @@ _FindMP3s(void)
|
|||
} else
|
||||
bShortcut = false;
|
||||
|
||||
aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]);
|
||||
aStream[0] = new CStream(filepath, &ALStreamSources[0], ALStreamBuffers[0]);
|
||||
|
||||
if (aStream[0] && aStream[0]->IsOpened())
|
||||
{
|
||||
|
@ -989,7 +998,7 @@ cSampleManager::Initialise(void)
|
|||
|
||||
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
|
||||
{
|
||||
aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0]);
|
||||
aStream[0] = new CStream(StreamedNameTable[i], &ALStreamSources[0], ALStreamBuffers[0]);
|
||||
|
||||
if ( aStream[0] && aStream[0]->IsOpened() )
|
||||
{
|
||||
|
@ -1672,7 +1681,7 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream)
|
|||
|
||||
strcpy(filename, StreamedNameTable[nFile]);
|
||||
|
||||
CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
CStream *stream = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
ASSERT(stream != NULL);
|
||||
|
||||
aStream[nStream] = stream;
|
||||
|
@ -1747,7 +1756,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
|
|||
nFile = 0;
|
||||
strcat(filename, StreamedNameTable[nFile]);
|
||||
|
||||
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
CStream* stream = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
ASSERT(stream != NULL);
|
||||
|
||||
aStream[nStream] = stream;
|
||||
|
@ -1771,12 +1780,12 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
|
|||
}
|
||||
|
||||
if (mp3->pLinkPath != NULL)
|
||||
aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
aStream[nStream] = new CStream(mp3->pLinkPath, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
else {
|
||||
strcpy(filename, _mp3DirectoryPath);
|
||||
strcat(filename, mp3->aFilename);
|
||||
|
||||
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
aStream[nStream] = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
}
|
||||
|
||||
if (aStream[nStream]->IsOpened()) {
|
||||
|
@ -1803,7 +1812,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
|
|||
{
|
||||
nFile = 0;
|
||||
strcat(filename, StreamedNameTable[nFile]);
|
||||
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
CStream* stream = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
ASSERT(stream != NULL);
|
||||
|
||||
aStream[nStream] = stream;
|
||||
|
@ -1827,12 +1836,12 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
|
|||
}
|
||||
|
||||
if (e->pLinkPath != NULL)
|
||||
aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
aStream[nStream] = new CStream(e->pLinkPath, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
else {
|
||||
strcpy(filename, _mp3DirectoryPath);
|
||||
strcat(filename, e->aFilename);
|
||||
|
||||
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
aStream[nStream] = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
}
|
||||
|
||||
if (aStream[nStream]->IsOpened()) {
|
||||
|
@ -1860,7 +1869,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
|
|||
|
||||
strcpy(filename, StreamedNameTable[nFile]);
|
||||
|
||||
CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
|
||||
CStream *stream = new CStream(filename, &ALStreamSources[nStream*2], ALStreamBuffers[nStream]);
|
||||
ASSERT(stream != NULL);
|
||||
|
||||
aStream[nStream] = stream;
|
||||
|
@ -1937,7 +1946,7 @@ cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffect
|
|||
{
|
||||
if ( nEffectFlag ) {
|
||||
if ( nStream == 1 || nStream == 2 )
|
||||
stream->SetVolume(2*128*nVolume*m_nEffectsVolume >> 14); // double the volume for now as it plays too quiet
|
||||
stream->SetVolume(128*nVolume*m_nEffectsVolume >> 14);
|
||||
else
|
||||
stream->SetVolume(m_nEffectsFadeVolume*nVolume*m_nEffectsVolume >> 14);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue