Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
Enumerations | |
enum | Error { NoError , OpenError , IOError , UnderrunError , FatalError } |
enum | State { ActiveState , SuspendedState , StoppedState , IdleState } |
enum | VolumeScale { LinearVolumeScale , CubicVolumeScale , LogarithmicVolumeScale , DecibelVolumeScale } |
Functions | |
Q_MULTIMEDIA_EXPORT float | convertVolume (float volume, VolumeScale from, VolumeScale to) |
Converts an audio volume from a volume scale to another, and returns the result. | |
enum QAudio::Error |
enum QAudio::State |
enum QAudio::VolumeScale |
float QAudio::convertVolume | ( | float | volume, |
VolumeScale | from, | ||
VolumeScale | to ) |
Converts an audio volume from a volume scale to another, and returns the result.
Depending on the context, different scales are used to represent audio volume. All Qt Multimedia classes that have an audio volume use a linear scale, the reason is that the loudness of a speaker is controlled by modulating its voltage on a linear scale. The human ear on the other hand, perceives loudness in a logarithmic way. Using a logarithmic scale for volume controls is therefore appropriate in most applications. The decibel scale is logarithmic by nature and is commonly used to define sound levels, it is usually used for UI volume controls in professional audio applications. The cubic scale is a computationally cheap approximation of a logarithmic scale, it provides more control over lower volume levels.
The following example shows how to convert the volume value from a slider control before passing it to a QMediaPlayer. As a result, the perceived increase in volume is the same when increasing the volume slider from 20 to 30 as it is from 50 to 60:
Definition at line 93 of file qtaudio.cpp.
References convertVolume(), CubicVolumeScale, DecibelVolumeScale, LinearVolumeScale, LOG100, LogarithmicVolumeScale, qFuzzyIsNull(), qMax(), and qPow().
Referenced by applyVolume(), and convertVolume().