Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Playing sound at volume above 100  (Read 4666 times)

0 Members and 1 Guest are viewing this topic.

dk123

  • Newbie
  • *
  • Posts: 49
    • View Profile
Playing sound at volume above 100
« 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.)

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Playing sound at volume above 100
« Reply #1 on: October 04, 2014, 08:12:07 pm »
Correct me if I am wrong, but this is a limit of OpenAL, not SFML.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Playing sound at volume above 100
« Reply #2 on: October 04, 2014, 08:39:53 pm »
The OpenAL specification says:

Quote
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.
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Playing sound at volume above 100
« Reply #3 on: October 05, 2014, 02:41:16 am »
Solution. hehe
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dmitry_t

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Playing sound at volume above 100
« Reply #4 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.

 

anything