内容表

上一话题

QAbstractVideoSurface

下一话题

QAudioBuffer

QAudio

QAudio namespace contains enums used by the audio classes. 更多

Inheritance diagram of PySide2.QtMultimedia.QAudio

概要

静态函数

详细描述

PySide2.QtMultimedia.QAudio. Error

常量

描述

QAudio.NoError

No errors have occurred

QAudio.OpenError

An error occurred opening the audio device

QAudio.IOError

An error occurred during read/write of audio device

QAudio.UnderrunError

Audio data is not being fed to the audio device at a fast enough rate

QAudio.FatalError

A non-recoverable error has occurred, the audio device is not usable at this time.

PySide2.QtMultimedia.QAudio. State

常量

描述

QAudio.ActiveState

Audio data is being processed, this state is set after start() is called and while audio data is available to be processed.

QAudio.SuspendedState

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

The audio device is closed, and is not processing any audio data

QAudio.IdleState

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

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.

PySide2.QtMultimedia.QAudio. 模式

常量

描述

QAudio.AudioOutput

音频输出设备

QAudio.AudioInput

音频输入设备

PySide2.QtMultimedia.QAudio. Role

This enum describes the role of an audio stream.

常量

描述

QAudio.UnknownRole

The role is unknown or undefined

QAudio.MusicRole

Music

QAudio.VideoRole

Soundtrack from a movie or a video

QAudio.VoiceCommunicationRole

Voice communications, such as telephony

QAudio.AlarmRole

Alarm

QAudio.NotificationRole

Notification, such as an incoming e-mail or a chat request

QAudio.RingtoneRole

Ringtone

QAudio.AccessibilityRole

For accessibility, such as with a screen reader

QAudio.SonificationRole

Sonification, such as with user interface sounds

QAudio.GameRole

游戏音频

QAudio.CustomRole

The role is specified by customAudioRole()

另请参阅

setAudioRole()

New in version 5.6.

PySide2.QtMultimedia.QAudio. VolumeScale

此枚举定义不同音频音量的比例缩放。

常量

描述

QAudio.LinearVolumeScale

线性比例缩放。 0.0 (0%) 为无声而 1.0 (100%) is full volume. All Qt Multimedia classes that have an audio volume use a linear scale.

QAudio.CubicVolumeScale

立方比例缩放。 0.0 (0%) 为无声而 1.0 (100%) 为全音量。

QAudio.LogarithmicVolumeScale

对数比例缩放。 0.0 (0%) 为无声而 1.0 (100%) is full volume. UI volume controls should usually use a logarithmic scale.

QAudio.DecibelVolumeScale

分贝 (dB、振幅) 对数比例缩放。 -200 为无声而 0 为全音量。

另请参阅

convertVolume()

New in version 5.8.

static PySide2.QtMultimedia.QAudio. convertVolume ( volume , from , to )
参数
返回类型

qreal

转换音频 volume from 音量比例缩放 to 另一,并返回结果。

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:

void applyVolume(int volumeSliderValue)
{
    // volumeSliderValue is in the range [0..100]
    qreal linearVolume = QAudio::convertVolume(volumeSliderValue / qreal(100.0),
                                               QAudio::LogarithmicVolumeScale,
                                               QAudio::LinearVolumeScale);
    player.setVolume(qRound(linearVolume * 100));
}