SFML community forums
Help => Audio => Topic started by: dk123 on October 04, 2014, 07:59:53 pm
-
The current implementation of sounds seems to limit
the volume at 100(%). It would be nice if sounds could
be played at higher volumes than they're original file volumes.
(ex. 250%, 500%, etc.)
-
Correct me if I am wrong, but this is a limit of OpenAL, not SFML.
-
The OpenAL specification says:
AL_GAIN larger than one (i.e. amplification) is permitted for source and listener.
However, the implementation is free to clamp the total gain (effective gain per-source
multiplied by the listener gain) to one to prevent overflow
So it depends on the OpenAL implementation. And there's nothing we can do in SFML.
-
Solution (http://audacity.sourceforge.net/). hehe
-
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.