Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QtAudio Namespace Reference

The QtAudio namespace contains enums used by the audio classes. More...

Typedefs

using Error = QAudio::Error
using State = QAudio::State
using VolumeScale = QAudio::VolumeScale

Functions

float convertVolume (float volume, VolumeScale from, VolumeScale to)
 Converts an audio volume from a volume scale to another, and returns the result.

Variables

constexpr auto NoError = QAudio::NoError
constexpr auto OpenError = QAudio::OpenError
constexpr auto IOError = QAudio::IOError
constexpr auto UnderrunError = QAudio::UnderrunError
constexpr auto FatalError = QAudio::FatalError
constexpr auto ActiveState = QAudio::ActiveState
constexpr auto SuspendedState = QAudio::SuspendedState
constexpr auto StoppedState = QAudio::StoppedState
constexpr auto IdleState = QAudio::IdleState
constexpr auto LinearVolumeScale = QAudio::LinearVolumeScale
constexpr auto CubicVolumeScale = QAudio::CubicVolumeScale
constexpr auto LogarithmicVolumeScale = QAudio::LogarithmicVolumeScale
constexpr auto DecibelVolumeScale = QAudio::DecibelVolumeScale

Detailed Description

The QtAudio namespace contains enums used by the audio classes.

\inmodule QtMultimedia

Typedef Documentation

◆ Error

Definition at line 52 of file qaudio.h.

◆ State

Definition at line 53 of file qaudio.h.

◆ VolumeScale

Definition at line 54 of file qaudio.h.

Function Documentation

◆ convertVolume()

float QtAudio::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 96 of file qtaudio.cpp.

Variable Documentation

◆ ActiveState

auto QtAudio::ActiveState = QAudio::ActiveState
inlineconstexpr

Definition at line 61 of file qaudio.h.

◆ CubicVolumeScale

auto QtAudio::CubicVolumeScale = QAudio::CubicVolumeScale
inlineconstexpr

Definition at line 66 of file qaudio.h.

◆ DecibelVolumeScale

auto QtAudio::DecibelVolumeScale = QAudio::DecibelVolumeScale
inlineconstexpr

Definition at line 68 of file qaudio.h.

◆ FatalError

auto QtAudio::FatalError = QAudio::FatalError
inlineconstexpr

Definition at line 60 of file qaudio.h.

◆ IdleState

auto QtAudio::IdleState = QAudio::IdleState
inlineconstexpr

Definition at line 64 of file qaudio.h.

◆ IOError

auto QtAudio::IOError = QAudio::IOError
inlineconstexpr

Definition at line 58 of file qaudio.h.

◆ LinearVolumeScale

auto QtAudio::LinearVolumeScale = QAudio::LinearVolumeScale
inlineconstexpr

Definition at line 65 of file qaudio.h.

◆ LogarithmicVolumeScale

auto QtAudio::LogarithmicVolumeScale = QAudio::LogarithmicVolumeScale
inlineconstexpr

Definition at line 67 of file qaudio.h.

◆ NoError

auto QtAudio::NoError = QAudio::NoError
inlineconstexpr

Definition at line 56 of file qaudio.h.

◆ OpenError

auto QtAudio::OpenError = QAudio::OpenError
inlineconstexpr

Definition at line 57 of file qaudio.h.

◆ StoppedState

auto QtAudio::StoppedState = QAudio::StoppedState
inlineconstexpr

Definition at line 63 of file qaudio.h.

◆ SuspendedState

auto QtAudio::SuspendedState = QAudio::SuspendedState
inlineconstexpr

Definition at line 62 of file qaudio.h.

◆ UnderrunError

auto QtAudio::UnderrunError = QAudio::UnderrunError
inlineconstexpr

Definition at line 59 of file qaudio.h.