1
Audio / Re: Playing sound at volume above 100
« on: May 30, 2022, 02:39:26 pm »
I needed to amplify too quiet sounds without using the Audacity.
So just to conclude.
You CAN pass a volume value greater than 100.
The OpenAL implementation clips too high values forcing them to be in the int16 range obviously.
So if you don't want the sound to be overloaded, the actual max volume value for a specific sound depends on the max sample values. E.g. having max absolute sample value equal to 3276 you can pass volume value up to 32767 / 3276 * 100 = 1000 (where 32767 is the max positive int16).
There are many ways to check the sample values, e.g. you can use the sf::SoundBuffer class to get samples.
I personally used a Python script like that:
import pyogg
ogg_file = pyogg.VorbisFile(file_path)
buffer = ogg_file.as_array()
print(buffer.min(), buffer.max())
P.S. Sorry for posting into a thread which is several years old.
So just to conclude.
You CAN pass a volume value greater than 100.
The OpenAL implementation clips too high values forcing them to be in the int16 range obviously.
So if you don't want the sound to be overloaded, the actual max volume value for a specific sound depends on the max sample values. E.g. having max absolute sample value equal to 3276 you can pass volume value up to 32767 / 3276 * 100 = 1000 (where 32767 is the max positive int16).
There are many ways to check the sample values, e.g. you can use the sf::SoundBuffer class to get samples.
I personally used a Python script like that:
import pyogg
ogg_file = pyogg.VorbisFile(file_path)
buffer = ogg_file.as_array()
print(buffer.min(), buffer.max())
P.S. Sorry for posting into a thread which is several years old.