Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer wav file playback speed is incorrect (Linux)
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer wav file playback speed is incorrect (Linux)

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 412 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.
  • J Offline
    J Offline
    JimmyJimJames
    wrote on last edited by
    #1

    I'm running Ubuntu server 18.04.0 on a x86 tablet computer.
    The manufacturer doesn't support Linux, but I was able to get audio working using the UCM stuff from here and jumping through a few hoops: https://github.com/plbossart/UCM

    I am running jackd and alsa on the tablet. The jackd seems to be fine, and here is its startup information:

    jackd[2149]: creating alsa driver ... hw:chtbswrt5672|-|1024|2|44100|0|0|nomon|swmeter|-|32bit
    jackd[2149]: configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
    jackd[2149]: ALSA: final selected sample format for playback: 24bit little-endian
    jackd[2149]: ALSA: use 2 periods for playback
    

    And audio seems to work fine via the command line with the aplay command:

    aplay /var/ftp/pub/beep.wav
    Playing WAVE '/var/ftp/pub/beep.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
    

    But, when I play the same wave file using an application that uses QMediaPlayer with this code:

    playlist = new QMediaPlaylist(this);
    playlist->addMedia(QUrl::fromLocalFile("/var/ftp/pub/beep.wav"));
    playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
    player = new QMediaPlayer(this);
    player->setPlaylist(playlist);
    playlist->setCurrentIndex(0);
    player->play();
    

    the sound plays back at the incorrect rate, as I hear a sound which is very high pitched and of a shorter duration.
    I'm guessing that the playback rate of the file (44100Hz) isn't being observed, and it's maybe being played back at 48000Hz?

    If I run this same test program on my laptop, it plays the wav file back with the correct pitch and speed, so it's something that I'm doing on this tablet....

    Does QMediaPlayer use the gstreamer stuff on Linux? Here is the package installation status for the gst* packages:

    dpkg -l gst*
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name                     Version           Architecture      Description
    +++-========================-=================-=================-=====================================================
    un  gstreamer1.0-alsa        <none>            <none>            (no description available)
    un  gstreamer1.0-audiosink   <none>            <none>            (no description available)
    un  gstreamer1.0-audiosource <none>            <none>            (no description available)
    ii  gstreamer1.0-gl:amd64    1.14.5-0ubuntu1~1 amd64             GStreamer plugins for GL
    un  gstreamer1.0-plugins-bad <none>            <none>            (no description available)
    ii  gstreamer1.0-plugins-bas 1.14.5-0ubuntu1~1 amd64             GStreamer plugins from the "base" set
    ii  gstreamer1.0-plugins-goo 1.14.5-0ubuntu1~1 amd64             GStreamer plugins from the "good" set
    un  gstreamer1.0-plugins-ugl <none>            <none>            (no description available)
    ii  gstreamer1.0-pulseaudio: 1.14.5-0ubuntu1~1 amd64             GStreamer plugin for PulseAudio
    un  gstreamer1.0-tools       <none>            <none>            (no description available)
    un  gstreamer1.0-videosink   <none>            <none>            (no description available)
    un  gstreamer1.0-videosource <none>            <none>            (no description available)
    un  gstreamer1.0-visualizati <none>            <none>            (no description available)
    ii  gstreamer1.0-x:amd64     1.14.5-0ubuntu1~1 amd64             GStreamer plugins for X11 and Pango
    

    Anyone know where my problem is, and if there's a way to get the QMediaPlayer to play the wav file correctly?

    Thanks!

    J 1 Reply Last reply
    0
    • J JimmyJimJames

      I'm running Ubuntu server 18.04.0 on a x86 tablet computer.
      The manufacturer doesn't support Linux, but I was able to get audio working using the UCM stuff from here and jumping through a few hoops: https://github.com/plbossart/UCM

      I am running jackd and alsa on the tablet. The jackd seems to be fine, and here is its startup information:

      jackd[2149]: creating alsa driver ... hw:chtbswrt5672|-|1024|2|44100|0|0|nomon|swmeter|-|32bit
      jackd[2149]: configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 2 periods
      jackd[2149]: ALSA: final selected sample format for playback: 24bit little-endian
      jackd[2149]: ALSA: use 2 periods for playback
      

      And audio seems to work fine via the command line with the aplay command:

      aplay /var/ftp/pub/beep.wav
      Playing WAVE '/var/ftp/pub/beep.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
      

      But, when I play the same wave file using an application that uses QMediaPlayer with this code:

      playlist = new QMediaPlaylist(this);
      playlist->addMedia(QUrl::fromLocalFile("/var/ftp/pub/beep.wav"));
      playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
      player = new QMediaPlayer(this);
      player->setPlaylist(playlist);
      playlist->setCurrentIndex(0);
      player->play();
      

      the sound plays back at the incorrect rate, as I hear a sound which is very high pitched and of a shorter duration.
      I'm guessing that the playback rate of the file (44100Hz) isn't being observed, and it's maybe being played back at 48000Hz?

      If I run this same test program on my laptop, it plays the wav file back with the correct pitch and speed, so it's something that I'm doing on this tablet....

      Does QMediaPlayer use the gstreamer stuff on Linux? Here is the package installation status for the gst* packages:

      dpkg -l gst*
      Desired=Unknown/Install/Remove/Purge/Hold
      | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
      |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
      ||/ Name                     Version           Architecture      Description
      +++-========================-=================-=================-=====================================================
      un  gstreamer1.0-alsa        <none>            <none>            (no description available)
      un  gstreamer1.0-audiosink   <none>            <none>            (no description available)
      un  gstreamer1.0-audiosource <none>            <none>            (no description available)
      ii  gstreamer1.0-gl:amd64    1.14.5-0ubuntu1~1 amd64             GStreamer plugins for GL
      un  gstreamer1.0-plugins-bad <none>            <none>            (no description available)
      ii  gstreamer1.0-plugins-bas 1.14.5-0ubuntu1~1 amd64             GStreamer plugins from the "base" set
      ii  gstreamer1.0-plugins-goo 1.14.5-0ubuntu1~1 amd64             GStreamer plugins from the "good" set
      un  gstreamer1.0-plugins-ugl <none>            <none>            (no description available)
      ii  gstreamer1.0-pulseaudio: 1.14.5-0ubuntu1~1 amd64             GStreamer plugin for PulseAudio
      un  gstreamer1.0-tools       <none>            <none>            (no description available)
      un  gstreamer1.0-videosink   <none>            <none>            (no description available)
      un  gstreamer1.0-videosource <none>            <none>            (no description available)
      un  gstreamer1.0-visualizati <none>            <none>            (no description available)
      ii  gstreamer1.0-x:amd64     1.14.5-0ubuntu1~1 amd64             GStreamer plugins for X11 and Pango
      

      Anyone know where my problem is, and if there's a way to get the QMediaPlayer to play the wav file correctly?

      Thanks!

      J Offline
      J Offline
      JimmyJimJames
      wrote on last edited by
      #2

      @JimmyJimJames

      And to add to my misery....

      I converted the wav files in question from 44100Hz to 48000Hz and they still play fast via Qt, but normal from aplay.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JimmyJimJames
        wrote on last edited by
        #3

        I have figured out a solution that works for me.
        I modified my call to jackd to pass the -S option to the ALSA driver in the jackd line.

        /usr/bin/jackd -d alsa -P hw:chtbswrt5672 -S
        

        Once I did that, the playback speed/pitch is now correct.

        Here is what the man page says for the -S option:

           -S, --shorts
                  Try to configure card for 16-bit samples first, only trying 32-bits if unsuccessful.  Default is to prefer 32-bit samples.
        
        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