Phonon's AudioOutput volume setting



  • 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.



  • 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).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.