QAudio 名称空间

QAudio 名称空间包含用于音频类的枚举。 更多...

头: #include <QAudio>
qmake: QT += multimedia

    类型

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

    函数

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

    详细描述

    类型文档编制

    enum QAudio:: Error

    常量 描述
    QAudio::NoError 0 没有出现错误
    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

    常量 描述
    QAudio::AudioOutput 1 音频输出设备
    QAudio::AudioInput 0 音频输入设备

    enum QAudio:: Role

    此枚举描述音频流的角色。

    常量 描述
    QAudio::UnknownRole 0 角色未知或未定义字节序
    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 闹钟
    QAudio::NotificationRole 5 Notification, such as an incoming e-mail or a chat request
    QAudio::RingtoneRole 6 手机铃声
    QAudio::AccessibilityRole 7 For accessibility, such as with a screen reader
    QAudio::SonificationRole 8 Sonification, such as with user interface sounds
    QAudio::GameRole 9 游戏音频
    QAudio::CustomRole 10 The role is specified by QMediaPlayer::customAudioRole ()

    该枚举在 Qt 5.6 引入或被修改。

    另请参阅 QMediaPlayer::setAudioRole ().

    enum QAudio:: State

    常量 描述
    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

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

    常量 描述
    QAudio::LinearVolumeScale 0 线性比例缩放。 0.0 (0%) 为无声而 1.0 (100%) is full volume. All Qt Multimedia classes that have an audio volume use a linear scale.
    QAudio::CubicVolumeScale 1 立方比例缩放。 0.0 (0%) 为无声而 1.0 (100%) 为全音量。
    QAudio::LogarithmicVolumeScale 2 对数比例缩放。 0.0 (0%) 为无声而 1.0 (100%) is full volume. UI volume controls should usually use a logarithmic scale.
    QAudio::DecibelVolumeScale 3 分贝 (dB、振幅) 对数比例缩放。 -200 为无声而 0 为全音量。

    该枚举在 Qt 5.8 引入或被修改。

    另请参阅 QAudio::convertVolume ().

    函数文档编制

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

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

    从属上下文,表示音频音量是使用不同刻度。所有拥有音频音量的 Qt Multimedia 类都使用线性刻度,原因是扬声器响度是通过线性刻度调制其电压来控制的。另一方面,人的耳朵以对数方式感知响度。因此,在大多数应用程序中,音量控制使用对数刻度很合适。分贝刻度本质上是对数的,且常用于定义声明级别,通常用于专业音频应用程序 UI 音量控制。立方刻度是对数刻度的便宜计算近似,它提供对较低音量级别的更多控制。

    以下范例展示如何从滑块控件转换音量值,先于把它传递给 QMediaPlayer 。因此,感知音量递增一样,当把音量滑块从 20 递增到 30 时,就像从 50 到 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));
    }
    					

    该函数在 Qt 5.8 引入。

    另请参阅 VolumeScale , QMediaPlayer::setVolume (), QAudioOutput::setVolume (), QAudioInput::setVolume (), QSoundEffect::setVolume (),和 QMediaRecorder::setVolume ().