Auf dieser Seite

QAudioFormat Class

Die Klasse „QAudioFormat“ speichert Informationen zu den Parametern des Audiostreams. Mehr...

Header: #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 Elemente

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)

Ausführliche Beschreibung

Ein Audioformat legt fest, wie die Daten in einem rohen Audiostream angeordnet sind. Zum Beispiel, wie der Stream interpretiert werden soll.

QAudioFormat enthält Parameter, die festlegen, wie die Audio-Abtastdaten angeordnet sind. Dazu gehören die Frequenz, die Anzahl der Kanäle und das Abtastformat. Die folgende Tabelle beschreibt diese Parameter im Detail.

ParameterBeschreibung
AbtastrateAbtastungen pro Sekunde der Audiodaten in Hertz.
Anzahl der KanäleDie Anzahl der Audiokanäle (typischerweise einer für Mono oder zwei für Stereo). Dies ist die Anzahl aufeinanderfolgender Samples, die zusammen einen Frame im Stream bilden
AbtastformatDas 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 Audiostreams festzulegen, oder mit QAudioBuffer, wenn mit Samples im Speicher gearbeitet wird.

Über Funktionen in QAudioDevice können Sie Audioformate abrufen, die mit dem verwendeten Audiogerät kompatibel sind. Mit dieser Klasse können Sie außerdem die verfügbaren Parameterwerte für ein Gerät abfragen, sodass Sie die Parameter selbst festlegen können. Weitere Informationen finden Sie in der Klassenbeschreibung von QAudioDevice. Sie müssen das Format der Audiostreams kennen, die Sie abspielen oder aufnehmen möchten.

Die Samples aller Kanäle werden miteinander verschachtelt. Ein Sample pro Kanal für denselben Zeitpunkt wird in „ Qt Multimedia “ (und an anderen Stellen) als „Frame“ bezeichnet.

Dokumentation zu Mitgliedstypen

enum QAudioFormat::AudioChannelPosition

Beschreibt die möglichen Positionen der Audiokanäle. Diese entsprechen der Standarddefinition, die in der 22.2-Surround-Sound-Konfiguration verwendet wird.

KonstantWertBeschreibung
QAudioFormat::UnknownPosition0Unbekannte Position
QAudioFormat::FrontLeft1 
QAudioFormat::FrontRight2 
QAudioFormat::FrontCenter3 
QAudioFormat::LFE4Tieffrequenzkanal (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 Enumeration beschreibt ein standardisiertes Audiokanal-Layout. Die gängigsten Konfigurationen sind Mono, Stereo, 2.1 (Stereo plus Tiefton), 5.1-Surround und 7.1-Surround.

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

enum QAudioFormat::SampleFormat

Qt erwartet und verwendet stets Samples in der Endianness der Host-Plattform. Wenn Sie Audiodaten aus externen Quellen selbst verarbeiten, stellen Sie sicher, dass Sie diese in die richtige Endianness konvertieren, bevor Sie sie in eine „ QAudioSink “ oder „ QAudioBuffer “ schreiben.

KonstanteWertBeschreibung
QAudioFormat::Unknown0Nicht festgelegt
QAudioFormat::UInt81Samples sind 8-Bit-Ganzzahlen ohne Vorzeichen
QAudioFormat::Int162Die Abtastwerte sind 16-Bit-Ganzzahlen mit Vorzeichen
QAudioFormat::Int323Die Abtastwerte sind 32-Bit-Ganzzahlen mit Vorzeichen
QAudioFormat::Float4Die Samples sind Gleitkommazahlen

Dokumentation der Member-Funktionen

[implicit] QAudioFormat::QAudioFormat()

Erstellt ein neues Audioformat.

Die Werte werden wie folgt initialisiert:

[implicit] QAudioFormat::QAudioFormat(const QAudioFormat &other)

Erstellen Sie ein neues Audioformat mithilfe von „ other “.

[noexcept implicit] QAudioFormat::~QAudioFormat()

Lösche dieses Audioformat.

qint32 QAudioFormat::bytesForDuration(qint64 microseconds) const

Gibt die Anzahl der Bytes zurück, die für dieses Audioformat für „ microseconds “ benötigt werden.

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

Beachten Sie, dass es zu Rundungen kommen kann, wenn „ microseconds “ kein 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 ungültig ist.

Siehe auch ` bytesForDuration()`.

[constexpr] int QAudioFormat::bytesPerFrame() const

Gibt die Anzahl der Bytes zurück, die zur Darstellung eines Frames (eines Samples in jedem Kanal) in diesem Format erforderlich sind.

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

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

Gibt die Anzahl der Bytes zurück, die zur Darstellung eines Samples in diesem Format erforderlich sind.

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 für die Kanalanzahl zurück.

Siehe auch „ setChannelCount()“.

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

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

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

Gibt eine Standard-Kanalkonfiguration für „ channelCount “ zurück.

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

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 ungültig ist.

Beachten Sie, dass es zu Rundungen kommen kann, wenn „ bytes “ kein 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 Rundungsabweichungen kommen kann, wenn „ byteCount “ kein exaktes Vielfaches der Anzahl der Bytes pro Frame ist.

Jeder Frame enthält einen 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 von „ sample “ auf einen Wert zwischen -1 und 1. Die Vorgehensweise hängt vom jeweiligen QaudioFormat ab.

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

Gibt das aktuelle Sample-Format 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)

Stellt die Kanalkonfiguration auf „ config “ ein.

Stellt die Kanalkonfiguration des Audioformats auf eine der Standard-Audiokanalkonfigurationen ein.

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

Siehe auch „ channelConfig()“.

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

Legt die Anzahl der Kanäle auf channels fest. Durch diese Einstellung wird auch die Kanalkonfiguration auf ChannelConfigUnknown festgelegt.

Siehe auch channelCount().

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

Legt das Sample-Format auf „ format “ fest.

Siehe auch „ sampleFormat()“ und „ QAudioFormat::SampleFormat “.

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

Stellt die Abtastrate auf samplerate in Hertz ein.

Siehe auch sampleRate().

Verwandte Themen für Nichtmitglieder

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

Gibt „ true “ zurück, wenn das Audioformat „ a “ nicht mit „ b “ übereinstimmt; andernfalls wird „ false “ zurückgegeben.

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

Gibt „ true “ zurück, wenn das Audioformat „ a “ mit „ b “ übereinstimmt; andernfalls wird „ false “ zurückgegeben.

© 2026 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.