QAudioFormat Class

Die Klasse QAudioFormat speichert Informationen über Audiostromparameter. Mehr...

Kopfzeile: #include <QAudioFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia

Öffentliche Typen

enum AudioChannelPosition { UnknownPosition, FrontLeft, FrontRight, FrontCenter, LFE, …, BottomFrontRight }
enum ChannelConfig { ChannelConfigUnknown, ChannelConfigMono, ChannelConfigStereo, ChannelConfig2Dot1, ChannelConfig3Dot0, …, ChannelConfigSurround7Dot1 }
enum SampleFormat { Unknown, UInt8, Int16, Int32, Float }

Öffentliche Funktionen

QAudioFormat()
QAudioFormat(const QAudioFormat &other)
~QAudioFormat()
qint32 bytesForDuration(qint64 microseconds) const
qint32 bytesForFrames(qint32 frameCount) const
int bytesPerFrame() const
int bytesPerSample() const
QAudioFormat::ChannelConfig channelConfig() const
int channelCount() const
int channelOffset(QAudioFormat::AudioChannelPosition channel) const
qint64 durationForBytes(qint32 bytes) const
qint64 durationForFrames(qint32 frameCount) const
qint32 framesForBytes(qint32 byteCount) const
qint32 framesForDuration(qint64 microseconds) const
bool isValid() const
float normalizedSampleValue(const void *sample) const
QAudioFormat::SampleFormat sampleFormat() const
int sampleRate() const
void setChannelConfig(QAudioFormat::ChannelConfig config)
void setChannelCount(int channels)
void setSampleFormat(QAudioFormat::SampleFormat format)
void setSampleRate(int samplerate)

Statische öffentliche Mitglieder

QAudioFormat::ChannelConfig channelConfig(Args... channels)
QAudioFormat::ChannelConfig defaultChannelConfigForChannelCount(int channelCount)
bool operator!=(const QAudioFormat &a, const QAudioFormat &b)
bool operator==(const QAudioFormat &a, const QAudioFormat &b)

Detaillierte Beschreibung

Ein Audioformat gibt an, wie die Daten in einem rohen Audiostrom angeordnet sind. Zum Beispiel, wie der Datenstrom interpretiert werden soll.

QAudioFormat enthält Parameter, die angeben, wie die Audio-Sample-Daten angeordnet sind. Dies sind die Frequenz, die Anzahl der Kanäle und das Sampleformat. In der folgenden Tabelle werden diese Parameter näher beschrieben.

ParameterBeschreibung
AbtastrateSamples pro Sekunde der Audiodaten in Hertz.
Anzahl der KanäleDie Anzahl der Audiokanäle (normalerweise einer für Mono oder zwei für Stereo). Dies ist die Anzahl der aufeinanderfolgenden Samples, die zusammen einen Frame im Stream bilden.
Format der SamplesDas Format der Audio-Samples im Stream

Diese Klasse wird in Verbindung mit QAudioSource oder QAudioSink verwendet, um die Parameter des zu lesenden oder zu schreibenden Audiostroms anzugeben, oder mit QAudioBuffer, wenn es um Samples im Speicher geht.

Über die Funktionen in QAudioDevice können Sie Audioformate erhalten, die mit dem verwendeten Audiogerät kompatibel sind. Mit dieser Klasse können Sie auch die verfügbaren Parameterwerte für ein Gerät abfragen, so dass Sie die Parameter selbst einstellen können. Siehe die Beschreibung der Klasse QAudioDevice für weitere Details. Sie müssen das Format der Audioströme kennen, die Sie abspielen oder aufnehmen möchten.

Die Samples für alle Kanäle werden verschachtelt. Ein Sample für jeden Kanal zum gleichen Zeitpunkt wird in Qt Multimedia (und an anderen Stellen) als Frame bezeichnet.

Dokumentation zum Membertyp

enum QAudioFormat::AudioChannelPosition

Beschreibt die möglichen Audiokanalpositionen. Diese entsprechen der Standarddefinition, die in der 22.2-Surround-Sound-Konfiguration verwendet wird.

KonstanteWertBeschreibung
QAudioFormat::UnknownPosition0Unbekannte Position
QAudioFormat::FrontLeft1
QAudioFormat::FrontRight2
QAudioFormat::FrontCenter3
QAudioFormat::LFE4Niederfrequenz-Effektkanal (Subwoofer)
QAudioFormat::BackLeft5
QAudioFormat::BackRight6
QAudioFormat::FrontLeftOfCenter7
QAudioFormat::FrontRightOfCenter8
QAudioFormat::BackCenter9
QAudioFormat::LFE219
QAudioFormat::SideLeft10
QAudioFormat::SideRight11
QAudioFormat::TopFrontLeft13
QAudioFormat::TopFrontRight15
QAudioFormat::TopFrontCenter14
QAudioFormat::TopCenter12
QAudioFormat::TopBackLeft16
QAudioFormat::TopBackRight18
QAudioFormat::TopSideLeft20
QAudioFormat::TopSideRight21
QAudioFormat::TopBackCenter17
QAudioFormat::BottomFrontCenter22
QAudioFormat::BottomFrontLeft23
QAudioFormat::BottomFrontRight24

enum QAudioFormat::ChannelConfig

Diese Aufzählung beschreibt ein standardisiertes Audiokanal-Layout. Die gebräuchlichsten Konfigurationen sind Mono, Stereo, 2.1 (Stereo plus Niederfrequenz), 5.1 Surround und 7.1 Surround.

KonstanteWertBeschreibung
QAudioFormat::ChannelConfigUnknown0Die Kanalkonfiguration ist nicht bekannt.
QAudioFormat::ChannelConfigMonoQtPrivate::channelConfig(FrontCenter)Das Audiomaterial hat einen Center-Kanal.
QAudioFormat::ChannelConfigStereoQtPrivate::channelConfig(FrontLeft, FrontRight)Das Audiomaterial hat zwei Kanäle, links und rechts.
QAudioFormat::ChannelConfig2Dot1QtPrivate::channelConfig(FrontLeft, FrontRight, LFE)Das Audiomaterial hat drei Kanäle: Links, Rechts und LFE (Low Frequency Effect).
QAudioFormat::ChannelConfig3Dot0QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter)Das Audiosignal hat drei Kanäle, Links, Rechts und Center.
QAudioFormat::ChannelConfig3Dot1QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, LFE)Das Audiosignal hat vier Kanäle: Links, Rechts, Center und LFE (Niederfrequenzeffekt).
QAudioFormat::ChannelConfigSurround5Dot0QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, BackLeft, BackRight)Das Audiosignal hat fünf Kanäle: Links, Rechts, Center, BackLeft und BackRight.
QAudioFormat::ChannelConfigSurround5Dot1QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, LFE, BackLeft, BackRight)Der Ton hat 6 Kanäle: Links, Rechts, Center, LFE, BackLeft und BackRight.
QAudioFormat::ChannelConfigSurround7Dot0QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, BackLeft, BackRight, SideLeft, SideRight)Der Ton hat 7 Kanäle, Links, Rechts, Center, BackLeft, BackRight, SideLeft und SideRight.
QAudioFormat::ChannelConfigSurround7Dot1QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, LFE, BackLeft, BackRight, SideLeft, SideRight)Der Ton hat 8 Kanäle: Links, Rechts, Center, LFE, BackLeft, BackRight, SideLeft und SideRight.

enum QAudioFormat::SampleFormat

Qt wird immer Samples in der Endianness der Host-Plattform erwarten und verwenden. Wenn Sie selbst Audiodaten aus externen Quellen verarbeiten, stellen Sie sicher, dass Sie sie in die korrekte Endianness konvertieren, bevor Sie sie in eine QAudioSink oder QAudioBuffer schreiben.

KonstanteWertBeschreibung
QAudioFormat::Unknown0Nicht gesetzt
QAudioFormat::UInt81Samples sind 8-Bit-Ganzzahlen ohne Vorzeichen
QAudioFormat::Int162Abtastwerte sind 16-Bit-Ganzzahlen mit Vorzeichen
QAudioFormat::Int323Abtastwerte sind 32-Bit-Ganzzahlen mit Vorzeichen
QAudioFormat::Float4Stichproben sind Fließkommazahlen

Dokumentation der Mitgliedsfunktionen

[noexcept default] QAudioFormat::QAudioFormat()

Konstruiert ein neues Audioformat.

Die Werte werden wie folgt initialisiert:

[noexcept default] QAudioFormat::QAudioFormat(const QAudioFormat &other)

Konstruieren Sie ein neues Audioformat mit other.

[noexcept default] QAudioFormat::~QAudioFormat()

Zerstören Sie dieses Audioformat.

qint32 QAudioFormat::bytesForDuration(qint64 microseconds) const

Gibt die Anzahl der für dieses Audioformat erforderlichen Bytes für microseconds zurück.

Gibt 0 zurück, wenn dieses Format nicht gültig ist.

Beachten Sie, dass es zu Rundungen kommen kann, wenn microseconds nicht ein exakter Bruchteil von sampleRate() ist.

Siehe auch durationForBytes().

qint32 QAudioFormat::bytesForFrames(qint32 frameCount) const

Gibt die Anzahl der Bytes zurück, die für frameCount Frames dieses Formats benötigt werden.

Gibt 0 zurück, wenn dieses Format nicht gültig ist.

Siehe auch bytesForDuration().

[constexpr] int QAudioFormat::bytesPerFrame() const

Gibt die Anzahl der Bytes zurück, die erforderlich sind, um einen Frame (ein Sample in jedem Kanal) in diesem Format darzustellen.

Gibt 0 zurück, wenn dieses Format ungültig ist.

[constexpr noexcept] int QAudioFormat::bytesPerSample() const

Gibt die Anzahl der Bytes zurück, die erforderlich sind, um ein Sample in diesem Format darzustellen.

Gibt 0 zurück, wenn dieses Format ungültig ist.

[constexpr noexcept] QAudioFormat::ChannelConfig QAudioFormat::channelConfig() const

Gibt die aktuelle Kanalkonfiguration zurück.

Siehe auch setChannelConfig().

[static constexpr] template <typename... Args> QAudioFormat::ChannelConfig QAudioFormat::channelConfig(Args... channels)

Gibt die aktuelle Kanalkonfiguration für die angegebene channels zurück.

[constexpr noexcept] int QAudioFormat::channelCount() const

Gibt den aktuellen Wert der Kanalanzahl zurück.

Siehe auch setChannelCount().

[noexcept] int QAudioFormat::channelOffset(QAudioFormat::AudioChannelPosition channel) const

Gibt die Position eines bestimmten Audiokanals channel innerhalb eines Audio-Frames für das angegebene Format zurück. Gibt -1 zurück, wenn der Kanal für dieses Format nicht existiert oder die Kanalkonfiguration unbekannt ist.

[static] QAudioFormat::ChannelConfig QAudioFormat::defaultChannelConfigForChannelCount(int channelCount)

Gibt eine Standardkanalkonfiguration für channelCount zurück.

Standardkonfigurationen sind für bis zu 8 Kanäle definiert und entsprechen den Standardkonfigurationen Mono, Stereo und Surround. Bei einer höheren Anzahl von Kanälen werden einfach die ersten channelCount Audiokanäle verwendet, die in QAudioFormat::AudioChannelPosition definiert sind.

qint64 QAudioFormat::durationForBytes(qint32 bytes) const

Gibt die Anzahl der Mikrosekunden zurück, die durch bytes in diesem Format dargestellt werden.

Gibt 0 zurück, wenn dieses Format nicht gültig ist.

Beachten Sie, dass es zu Rundungen kommen kann, wenn bytes nicht ein exaktes Vielfaches der Anzahl der Bytes pro Frame ist.

Siehe auch bytesForDuration().

qint64 QAudioFormat::durationForFrames(qint32 frameCount) const

Gibt die Anzahl der Mikrosekunden zurück, die durch frameCount Frames in diesem Format dargestellt werden.

qint32 QAudioFormat::framesForBytes(qint32 byteCount) const

Gibt die Anzahl der Frames zurück, die durch byteCount in diesem Format dargestellt werden.

Beachten Sie, dass es zu Rundungen kommen kann, wenn byteCount kein exaktes Vielfaches der Anzahl der Bytes pro Frame ist.

Jeder Frame hat ein Sample pro Kanal.

Siehe auch framesForDuration().

qint32 QAudioFormat::framesForDuration(qint64 microseconds) const

Gibt die Anzahl der Frames zurück, die zur Darstellung von microseconds in diesem Format erforderlich sind.

Beachten Sie, dass es zu Rundungen kommen kann, wenn microseconds kein exakter Bruchteil von sampleRate() ist.

[constexpr noexcept] bool QAudioFormat::isValid() const

Gibt true zurück, wenn alle Parameter gültig sind.

float QAudioFormat::normalizedSampleValue(const void *sample) const

Normalisiert den Wert sample auf eine Zahl zwischen -1 und 1. Die Methode hängt vom QaudioFormat ab.

[constexpr noexcept] QAudioFormat::SampleFormat QAudioFormat::sampleFormat() const

Gibt das aktuelle Musterformat zurück.

Siehe auch setSampleFormat().

[constexpr noexcept] int QAudioFormat::sampleRate() const

Gibt die aktuelle Abtastrate in Hertz zurück.

Siehe auch setSampleRate().

[noexcept] void QAudioFormat::setChannelConfig(QAudioFormat::ChannelConfig config)

Setzt die Kanalkonfiguration auf config.

Setzt die Kanalkonfiguration des Audioformats auf eine der Standard-Audiokanalkonfigurationen.

Hinweis: Dadurch wird auch die Anzahl der Kanäle geändert.

Siehe auch channelConfig().

[constexpr noexcept] void QAudioFormat::setChannelCount(int channels)

Setzt die Kanalanzahl auf channels. Wenn Sie dies einstellen, wird auch die Kanalkonfiguration auf ChannelConfigUnknown gesetzt.

Siehe auch channelCount().

[constexpr noexcept] void QAudioFormat::setSampleFormat(QAudioFormat::SampleFormat format)

Setzt das Beispielformat auf format.

Siehe auch sampleFormat() und QAudioFormat::SampleFormat.

[constexpr noexcept] void QAudioFormat::setSampleRate(int samplerate)

Setzt die Abtastrate auf samplerate in Hertz.

Siehe auch sampleRate().

Verwandte Nicht-Mitglieder

bool operator!=(const QAudioFormat &a, const QAudioFormat &b)

Gibt true zurück, wenn das Audioformat a nicht gleich b ist, andernfalls gibt es false zurück.

bool operator==(const QAudioFormat &a, const QAudioFormat &b)

Gibt true zurück, wenn das Audioformat a gleich b ist, andernfalls gibt es false zurück.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.