QAudioDevice and (un)supported QAudioFormat formats
-
The following simple code
int main(int argc, char** argv) { QApplication app(argc, argv); QAudioFormat fmt; fmt.setSampleRate(44100); fmt.setChannelCount(2); fmt.setSampleFormat(QAudioFormat::Float); const auto devices = QMediaDevices::audioOutputs(); for (const QAudioDevice& dev : devices) { qDebug() << "device" << dev.description(); qDebug() << "sampleRate min" << dev.minimumSampleRate() << "max" << dev.maximumSampleRate(); qDebug() << "channelCount min" << dev.minimumChannelCount() << "max" << dev.maximumChannelCount(); qDebug() << "preferredFormat" << dev.preferredFormat(); qDebug() << "format" << fmt << "isFormatSupported" << dev.isFormatSupported(fmt); qDebug(); } return app.exec(); }
will give me the following output
device "DENON-AVRHD (NVIDIA High Definition Audio)" sampleRate min 48000 max 48000 channelCount min 5 max 6 preferredFormat QAudioFormat( 48000 Hz, 6 Channels, Float Format ) format QAudioFormat( 44100 Hz, 2 Channels, Float Format ) isFormatSupported false device "DELL U2715H (NVIDIA High Definition Audio)" sampleRate min 48000 max 48000 channelCount min 2 max 2 preferredFormat QAudioFormat( 48000 Hz, 2 Channels, Float Format ) format QAudioFormat( 44100 Hz, 2 Channels, Float Format ) isFormatSupported false device "Realtek Digital Output (Realtek High Definition Audio)" sampleRate min 48000 max 48000 channelCount min 2 max 2 preferredFormat QAudioFormat( 48000 Hz, 2 Channels, Float Format ) format QAudioFormat( 44100 Hz, 2 Channels, Float Format ) isFormatSupported false
which I try to make sense of. As stated I indeed use a Nvidia Graphics Card for audio output. That device very much supports different sample rate and channel counts, but the code tells me that ALL devices can handle a sample rate of 48000 ONLY, as this is the min and max value. Similarly no device would handle mono output according to this text. So with that knowledge the example QAudioFormat of 44100 Stereo is rejected via the
isFormatSupported()
function. But really?My System is Windows 11, Qt 6.8.2, MSVC 2022, Nvidia Geforce RTX 3060
-
N Nhan Nguyen moved this topic from General and Desktop