![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
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 |
The QtAudio namespace contains enums used by the audio classes.
\inmodule QtMultimedia
using QtAudio::Error = QAudio::Error |
using QtAudio::State = QAudio::State |
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:
Definition at line 96 of file qtaudio.cpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |