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

Author Topic: [SOLVED] Getting the actual volume of a sound/music  (Read 7816 times)

0 Members and 1 Guest are viewing this topic.

WilliamKappler

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SOLVED] Getting the actual volume of a sound/music
« on: September 17, 2021, 02:04:13 am »
I have a use where I need to know the actual, post-attenuation (for 3D sounds) volume of sounds/music. It seems that, according to the API docs, there is no such function; there are only ways to get the various parameters that determine the attenuated volume. Is there some functionality I am missing to get the actual volume, post attenuation?

For instance, I set the sound volume to 0.5, but it's attenuated to half of that based on distance, I would want to know it is now 0.25.

The way the sound is attenuated is documented and I could reproduce it on my program's end, but it would of course be better if I could just ask SFML. That would cover the possibility of the formula changing in the future.
« Last Edit: September 17, 2021, 11:40:59 am by WilliamKappler »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Getting the actual volume of a sound/music
« Reply #1 on: September 17, 2021, 09:37:39 am »
There's no way to retrieve it.
SFML uses OpenAL underneath which will do the calculation. Not sure if OpenAL even reports the current "volume".
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

WilliamKappler

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Getting the actual volume of a sound/music
« Reply #2 on: September 17, 2021, 11:40:50 am »
Understandable. I'll just use that formula to get (approximate?) it on my end. Should be good enough. Thanks!