Qt 5.11 | Qt Multimedia | QAudio Namespace

Qt 5.11.3 Reference Documentation

# QAudio Namespace

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

Header: | #include <QAudio>
qmake: | QT += multimedia

## Types

enum | Error { NoError, OpenError, IOError, UnderrunError, FatalError }
enum | Mode { AudioOutput, AudioInput }
enum | Role { UnknownRole, MusicRole, VideoRole, VoiceCommunicationRole, ..., CustomRole }
enum | State { ActiveState, SuspendedState, StoppedState, IdleState, InterruptedState }
enum | VolumeScale { LinearVolumeScale, CubicVolumeScale, LogarithmicVolumeScale, DecibelVolumeScale }

## Functions

qreal | convertVolume(qreal volume, QAudio::VolumeScale from, QAudio::VolumeScale to)

## Detailed Description

The QAudio namespace contains enums used by the audio classes.

## Type Documentation

### enum QAudio::Error

Constant | Value | Description
--- | --- | ---
`QAudio::NoError` | `0` | No errors have occurred
`QAudio::OpenError` | `1` | An error occurred opening the audio device
`QAudio::IOError` | `2` | An error occurred during read/write of audio device
`QAudio::UnderrunError` | `3` | Audio data is not being fed to the audio device at a fast enough rate
`QAudio::FatalError` | `4` | A non-recoverable error has occurred, the audio device is not usable at this time.

### enum QAudio::Mode

Constant | Value | Description
--- | --- | ---
`QAudio::AudioOutput` | `1` | audio output device
`QAudio::AudioInput` | `0` | audio input device

### enum QAudio::Role

This enum describes the role of an audio stream.

Constant | Value | Description
--- | --- | ---
`QAudio::UnknownRole` | `0` | The role is unknown or undefined
`QAudio::MusicRole` | `1` | Music
`QAudio::VideoRole` | `2` | Soundtrack from a movie or a video
`QAudio::VoiceCommunicationRole` | `3` | Voice communications, such as telephony
`QAudio::AlarmRole` | `4` | Alarm
`QAudio::NotificationRole` | `5` | Notification, such as an incoming e-mail or a chat request
`QAudio::RingtoneRole` | `6` | Ringtone
`QAudio::AccessibilityRole` | `7` | For accessibility, such as with a screen reader
`QAudio::SonificationRole` | `8` | Sonification, such as with user interface sounds
`QAudio::GameRole` | `9` | Game audio
`QAudio::CustomRole` | `10` | The role is specified by QMediaPlayer::customAudioRole()

This enum was introduced or modified in Qt 5.6.

See also QMediaPlayer::setAudioRole().

### enum QAudio::State

Constant | Value | Description
--- | --- | ---
`QAudio::ActiveState` | `0` | Audio data is being processed, this state is set after start() is called and while audio data is available to be processed.
`QAudio::SuspendedState` | `1` | The audio stream is in a suspended state. Entered after suspend() is called or when another stream takes control of the audio device. In the later case, a call to resume will return control of the audio device to this stream. This should usually only be done upon user request.
`QAudio::StoppedState` | `2` | The audio device is closed, and is not processing any audio data
`QAudio::IdleState` | `3` | The QIODevice passed in has no data and audio system's buffer is empty, this state is set after start() is called and while no audio data is available to be processed.
`QAudio::InterruptedState` | `4` | This stream is in a suspended state because another higher priority stream currently has control of the audio device. Playback cannot resume until the higher priority stream relinquishes control of the audio device.

### enum QAudio::VolumeScale

This enum defines the different audio volume scales.

Constant | Value | Description
--- | --- | ---
`QAudio::LinearVolumeScale` | `0` | Linear scale. `0.0` (0%) is silence and `1.0` (100%) is full volume. All Qt Multimedia classes that have an audio volume use a linear scale.
`QAudio::CubicVolumeScale` | `1` | Cubic scale. `0.0` (0%) is silence and `1.0` (100%) is full volume.
`QAudio::LogarithmicVolumeScale` | `2` | Logarithmic Scale. `0.0` (0%) is silence and `1.0` (100%) is full volume. UI volume controls should usually use a logarithmic scale.
`QAudio::DecibelVolumeScale` | `3` | Decibel (dB, amplitude) logarithmic scale. `-200` is silence and `0` is full volume.

This enum was introduced or modified in Qt 5.8.

See also QAudio::convertVolume().

## Function Documentation

### qreal QAudio::convertVolume(qreal volume, QAudio::VolumeScale from, QAudio::VolumeScale to)