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>.
Loading...
Searching...
No Matches
QAudio Namespace Reference

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.
 

Enumeration Type Documentation

◆ Error

Enumerator
NoError 
OpenError 
IOError 
UnderrunError 
FatalError 

Definition at line 28 of file qaudio.h.

◆ State

Enumerator
ActiveState 
SuspendedState 
StoppedState 
IdleState 

Definition at line 29 of file qaudio.h.

◆ VolumeScale

Enumerator
LinearVolumeScale 
CubicVolumeScale 
LogarithmicVolumeScale 
DecibelVolumeScale 

Definition at line 31 of file qaudio.h.

Function Documentation

◆ convertVolume()

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:

See also
VolumeScale, QAudioSink::setVolume(), QAudioSource::setVolume(), QSoundEffect::setVolume()

Definition at line 93 of file qtaudio.cpp.

References convertVolume(), CubicVolumeScale, DecibelVolumeScale, LinearVolumeScale, LOG100, LogarithmicVolumeScale, qFuzzyIsNull(), qMax(), and qPow().

Referenced by applyVolume(), and convertVolume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: