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) |
Zugehörige Nicht-Members
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.
Parameter | Beschreibung |
---|---|
Abtastrate | Samples pro Sekunde der Audiodaten in Hertz. |
Anzahl der Kanäle | Die 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 Samples | Das 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.
Konstante | Wert | Beschreibung |
---|---|---|
QAudioFormat::UnknownPosition | 0 | Unbekannte Position |
QAudioFormat::FrontLeft | 1 | |
QAudioFormat::FrontRight | 2 | |
QAudioFormat::FrontCenter | 3 | |
QAudioFormat::LFE | 4 | Niederfrequenz-Effektkanal (Subwoofer) |
QAudioFormat::BackLeft | 5 | |
QAudioFormat::BackRight | 6 | |
QAudioFormat::FrontLeftOfCenter | 7 | |
QAudioFormat::FrontRightOfCenter | 8 | |
QAudioFormat::BackCenter | 9 | |
QAudioFormat::LFE2 | 19 | |
QAudioFormat::SideLeft | 10 | |
QAudioFormat::SideRight | 11 | |
QAudioFormat::TopFrontLeft | 13 | |
QAudioFormat::TopFrontRight | 15 | |
QAudioFormat::TopFrontCenter | 14 | |
QAudioFormat::TopCenter | 12 | |
QAudioFormat::TopBackLeft | 16 | |
QAudioFormat::TopBackRight | 18 | |
QAudioFormat::TopSideLeft | 20 | |
QAudioFormat::TopSideRight | 21 | |
QAudioFormat::TopBackCenter | 17 | |
QAudioFormat::BottomFrontCenter | 22 | |
QAudioFormat::BottomFrontLeft | 23 | |
QAudioFormat::BottomFrontRight | 24 |
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.
Konstante | Wert | Beschreibung |
---|---|---|
QAudioFormat::ChannelConfigUnknown | 0 | Die Kanalkonfiguration ist nicht bekannt. |
QAudioFormat::ChannelConfigMono | QtPrivate::channelConfig(FrontCenter) | Das Audiomaterial hat einen Center-Kanal. |
QAudioFormat::ChannelConfigStereo | QtPrivate::channelConfig(FrontLeft, FrontRight) | Das Audiomaterial hat zwei Kanäle, links und rechts. |
QAudioFormat::ChannelConfig2Dot1 | QtPrivate::channelConfig(FrontLeft, FrontRight, LFE) | Das Audiomaterial hat drei Kanäle: Links, Rechts und LFE (Low Frequency Effect). |
QAudioFormat::ChannelConfig3Dot0 | QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter) | Das Audiosignal hat drei Kanäle, Links, Rechts und Center. |
QAudioFormat::ChannelConfig3Dot1 | QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, LFE) | Das Audiosignal hat vier Kanäle: Links, Rechts, Center und LFE (Niederfrequenzeffekt). |
QAudioFormat::ChannelConfigSurround5Dot0 | QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, BackLeft, BackRight) | Das Audiosignal hat fünf Kanäle: Links, Rechts, Center, BackLeft und BackRight. |
QAudioFormat::ChannelConfigSurround5Dot1 | QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, LFE, BackLeft, BackRight) | Der Ton hat 6 Kanäle: Links, Rechts, Center, LFE, BackLeft und BackRight. |
QAudioFormat::ChannelConfigSurround7Dot0 | QtPrivate::channelConfig(FrontLeft, FrontRight, FrontCenter, BackLeft, BackRight, SideLeft, SideRight) | Der Ton hat 7 Kanäle, Links, Rechts, Center, BackLeft, BackRight, SideLeft und SideRight. |
QAudioFormat::ChannelConfigSurround7Dot1 | QtPrivate::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.
Konstante | Wert | Beschreibung |
---|---|---|
QAudioFormat::Unknown | 0 | Nicht gesetzt |
QAudioFormat::UInt8 | 1 | Samples sind 8-Bit-Ganzzahlen ohne Vorzeichen |
QAudioFormat::Int16 | 2 | Abtastwerte sind 16-Bit-Ganzzahlen mit Vorzeichen |
QAudioFormat::Int32 | 3 | Abtastwerte sind 32-Bit-Ganzzahlen mit Vorzeichen |
QAudioFormat::Float | 4 | Stichproben sind Fließkommazahlen |
Dokumentation der Mitgliedsfunktionen
[noexcept default]
QAudioFormat::QAudioFormat()
Konstruiert ein neues Audioformat.
Die Werte werden wie folgt initialisiert:
- sampleRate() = 0
- channelCount() = 0
- sampleFormat() = QAudioFormat::Unknown
[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.