Clamp floating-point sample data to +-1.0 for OpenAL
Fixes horrendously amplified horns being loud as fuck (yes, Vorbis can encode samples louder than 0 dB!)
This commit is contained in:
parent
6749b54968
commit
a8e14a6adb
1 changed files with 8 additions and 0 deletions
|
|
@ -790,6 +790,14 @@ static ALuint LoadDataIntoBuffer(void *input, size_t size)
|
|||
size = pos;
|
||||
samplerate = info.samplerate;
|
||||
sf_close(snd);
|
||||
|
||||
// SFC_SET_NORM_FLOAT apparently doesn't work, so gotta do this ourselves
|
||||
if (sample_format == Float)
|
||||
{
|
||||
float *norm = (float *)data;
|
||||
for (pos = 0; pos < size / sizeof(float); pos++)
|
||||
norm[pos] = CLAMP(norm[pos], -1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue