Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QMediaDevices audio outputs have wrong sample rates
Qt 6.11 is out! See what's new in the release blog

QMediaDevices audio outputs have wrong sample rates

Scheduled Pinned Locked Moved Solved Qt 6
qaudioformatqaudiooutputffmpegformat
3 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheEnigmist
    wrote on last edited by
    #1

    I'm trying to play some audio on output devices. Since I was getting some errors with format I printed all devices preferred foramt and found out that they accept a sample rate less than showed in system info.
    Here system info default audio output:
    5203501a-5758-4a56-a815-d86f9079e1bb-image.png
    Here what Qt6.3 says about preferred format:
    08ee41ea-576f-49db-8c30-d4c052a389ee-image.png

    This is sample code I used to create audio output:

    QAudioOutput *audioOutput = new QAudioOutput(QMediaDevices::defaultAudioOutput());
    for (QAudioDevice a : QMediaDevices::audioOutputs()) {
        QAudioFormat t = audioOutput->device().preferredFormat();
        qDebug() << a.description() << t.channelCount() << t.sampleRate() << t.sampleFormat();
    }
    QAudioSink* testAudio = new QAudioSink(audioOutput->device().preferredFormat(), baseWidget);
    QIODevice* audioDevice = testAudio->start();
    

    This leads to an incorrect playback of input file (a little bit "slowed" since his sample rate is 48000)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The preferred format is one thing, why not set the one that you actually want ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        The preferred format is one thing, why not set the one that you actually want ?

        T Offline
        T Offline
        TheEnigmist
        wrote on last edited by
        #3

        @SGaist Yes that was what I was trying. But I found the error. SampleFormat was set to Unknown instead of Int16. Now I only need to syncronize and write audio in the right rate

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved