mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-13 22:32:32 +00:00
Fixed screen twitches with "shakes" sound shader
Caused by inaccuracies in the precached amplitude data in the OpenAL backend, see https://github.com/dhewm/dhewm3/pull/71 for more details. Video sample (not mine): http://www.youtube.com/watch?v=ZUohifAbPW0 The "twitches" can also be observed right at the beginning of the mars_city2 map.
This commit is contained in:
parent
6407881cff
commit
351f5dc94f
1 changed files with 0 additions and 50 deletions
|
@ -496,28 +496,6 @@ void idSoundSample::Load( void ) {
|
|||
if ( alGetError() != AL_NO_ERROR ) {
|
||||
common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
|
||||
} else {
|
||||
// Compute amplitude block size
|
||||
int blockSize = 512 * objectInfo.nSamplesPerSec / 44100 ;
|
||||
|
||||
// Allocate amplitude data array
|
||||
amplitudeData = (byte *)soundCacheAllocator.Alloc( ( objectSize / blockSize + 1 ) * 2 * sizeof( short) );
|
||||
|
||||
// Creating array of min/max amplitude pairs per blockSize samples
|
||||
int i;
|
||||
for ( i = 0; i < objectSize; i+=blockSize ) {
|
||||
short min = 32767;
|
||||
short max = -32768;
|
||||
|
||||
int j;
|
||||
for ( j = 0; j < Min( objectSize - i, blockSize ); j++ ) {
|
||||
min = ((short *)nonCacheData)[ i + j ] < min ? ((short *)nonCacheData)[ i + j ] : min;
|
||||
max = ((short *)nonCacheData)[ i + j ] > max ? ((short *)nonCacheData)[ i + j ] : max;
|
||||
}
|
||||
|
||||
((short *)amplitudeData)[ ( i / blockSize ) * 2 ] = min;
|
||||
((short *)amplitudeData)[ ( i / blockSize ) * 2 + 1 ] = max;
|
||||
}
|
||||
|
||||
hardwareBuffer = true;
|
||||
}
|
||||
}
|
||||
|
@ -571,28 +549,6 @@ void idSoundSample::Load( void ) {
|
|||
if ( alGetError() != AL_NO_ERROR )
|
||||
common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
|
||||
else {
|
||||
// Compute amplitude block size
|
||||
int blockSize = 512 * objectInfo.nSamplesPerSec / 44100 ;
|
||||
|
||||
// Allocate amplitude data array
|
||||
amplitudeData = (byte *)soundCacheAllocator.Alloc( ( objectSize / blockSize + 1 ) * 2 * sizeof( short ) );
|
||||
|
||||
// Creating array of min/max amplitude pairs per blockSize samples
|
||||
int i;
|
||||
for ( i = 0; i < objectSize; i+=blockSize ) {
|
||||
short min = 32767;
|
||||
short max = -32768;
|
||||
|
||||
int j;
|
||||
for ( j = 0; j < Min( objectSize - i, blockSize ); j++ ) {
|
||||
min = ((short *)destData)[ i + j ] < min ? ((short *)destData)[ i + j ] : min;
|
||||
max = ((short *)destData)[ i + j ] > max ? ((short *)destData)[ i + j ] : max;
|
||||
}
|
||||
|
||||
((short *)amplitudeData)[ ( i / blockSize ) * 2 ] = min;
|
||||
((short *)amplitudeData)[ ( i / blockSize ) * 2 + 1 ] = max;
|
||||
}
|
||||
|
||||
hardwareBuffer = true;
|
||||
}
|
||||
|
||||
|
@ -601,12 +557,6 @@ void idSoundSample::Load( void ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Free memory if sample was loaded into hardware
|
||||
if ( hardwareBuffer ) {
|
||||
soundCacheAllocator.Free( nonCacheData );
|
||||
nonCacheData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fh.Close();
|
||||
|
|
Loading…
Reference in a new issue