Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Phonon's AudioOutput volume setting

Phonon's AudioOutput volume setting

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jimbo2
    wrote on last edited by
    #1

    Hi there, I'm using Phonon's AudioOutput (http://doc.qt.nokia.com/4.7/phonon-audiooutput.html) to render some pure audio streams and trying to control the volume levels. The volume property is a qreal and has the following description:

    bq. This is the current loudness of the output. (it is using Stevens' law to calculate the change in voltage internally).

    I found this pretty uninformative really. Here's the wikipedia article on Stevens' law: http://en.wikipedia.org/wiki/Stevens'_power_law

    I understand the concept of the law but not at all how the Qt Phonon implementation is utilising it or even what range it's using (this is running on Symbian at the moment). I can't use the volume slider widget because I need to do gradual cross fades between tracks rather than just using a static setting.

    From experimentation it seems to me that the range is 0.0 - 1.0 with 1.0 being the maximum volume setting. The values in between seem to be non-linear so I am assuming that the AudioOutput's volume setting corresponds to the symbol I in the Wikipedia page above, is anyone able to confirm whether this is on the right track please?

    I greatly appreciate any help with this, thank you for your time.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

      You should concentrate on the word "internally" when you have access to the source code:

      @static const qreal LOUDNESS_TO_VOLTAGE_EXPONENT = qreal(0.67);
      static const qreal VOLTAGE_TO_LOUDNESS_EXPONENT = qreal(1.0/LOUDNESS_TO_VOLTAGE_EXPONENT);

      void AudioOutput::setVolume(qreal volume)
      {
      K_D(AudioOutput);
      d->volume = volume;
      if (k_ptr->backendObject() && !d->muted) {
      // using Stevens' power law loudness is proportional to (sound pressure)^0.67
      // sound pressure is proportional to voltage:
      // p² \prop P \prop V²
      // => if a factor for loudness of x is requested
      INTERFACE_CALL(setVolume(pow(volume, VOLTAGE_TO_LOUDNESS_EXPONENT)));
      } else {
      emit volumeChanged(volume);
      }
      Platform::saveVolume(d->name, volume);
      }@

      I guess, you could call setVolume(pow(yourValue, 1.0/0.67)) if you want to cancel their exponentiation.
      And according to the gstreamer backend source code, for example, the range is 0.0 - 1.0 (but gstreamer can accept values up to 10.0).

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved