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. Why does QSoundEffect play sounds poorly unlike QMediaPlayer?
Forum Updated to NodeBB v4.3 + New Features

Why does QSoundEffect play sounds poorly unlike QMediaPlayer?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.1k Views
  • 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.
  • N Offline
    N Offline
    NightShadeI
    wrote on last edited by
    #1

    I'm trying to play a very short sound (definitely less than a second , maybe 0.2 seconds)

    I notice the sound is clear and crisp from QMediaPlayer, but not from QSoundEffect in Qt6 using C++

    The start or end of the sound gets cutoff in QSoundEffect which sounds counter-intuitive given its optimised for things like this

    I notice many applications to play audio files have this issue, but some play it really smoothly just like QMediaPlayer

    My operating system is Windows 10

    Christian EhrlicherC 1 Reply Last reply
    0
    • N NightShadeI

      I'm trying to play a very short sound (definitely less than a second , maybe 0.2 seconds)

      I notice the sound is clear and crisp from QMediaPlayer, but not from QSoundEffect in Qt6 using C++

      The start or end of the sound gets cutoff in QSoundEffect which sounds counter-intuitive given its optimised for things like this

      I notice many applications to play audio files have this issue, but some play it really smoothly just like QMediaPlayer

      My operating system is Windows 10

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please show your code.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      N 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Please show your code.

        N Offline
        N Offline
        NightShadeI
        wrote on last edited by
        #3

        Alright will share the code here, hadn't initially intended to provide it because I don't think it will be useful , and more fishing for an answer as to why the two are giving different results. Also I cannot provide the wav file by law, nonetheless, here is the relavent code:

        int main(int aArgc, char *aArgv[]) {
            QApplication myApplication{aArgc, aArgv};
        
            QMediaPlayer* myMediaPlayer = new QMediaPlayer;
            myMediaPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav"));
            
            QAudioOutput* myMediaAudioOutput = new QAudioOutput;
            myMediaAudioOutput->setVolume(1.f);
            myMediaPlayer->setAudioOutput(myMediaAudioOutput);
            
            QSoundEffect* myEffectPlayer = new QSoundEffect{};
            myEffectPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav"));
            myEffectPlayer->setVolume(1.f);
            myEffectPlayer->setLoopCount(1);
        
            // myEffectPlayer->play();
            myMediaPlayer->play();
        
            return myApplication.exec();
        }
        
        Christian EhrlicherC 1 Reply Last reply
        0
        • N NightShadeI

          Alright will share the code here, hadn't initially intended to provide it because I don't think it will be useful , and more fishing for an answer as to why the two are giving different results. Also I cannot provide the wav file by law, nonetheless, here is the relavent code:

          int main(int aArgc, char *aArgv[]) {
              QApplication myApplication{aArgc, aArgv};
          
              QMediaPlayer* myMediaPlayer = new QMediaPlayer;
              myMediaPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav"));
              
              QAudioOutput* myMediaAudioOutput = new QAudioOutput;
              myMediaAudioOutput->setVolume(1.f);
              myMediaPlayer->setAudioOutput(myMediaAudioOutput);
              
              QSoundEffect* myEffectPlayer = new QSoundEffect{};
              myEffectPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav"));
              myEffectPlayer->setVolume(1.f);
              myEffectPlayer->setLoopCount(1);
          
              // myEffectPlayer->play();
              myMediaPlayer->play();
          
              return myApplication.exec();
          }
          
          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @NightShadeI Ok, th code looks good and I don't see an obvious error. Please create a bug report and post the bug number here.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          N 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            @NightShadeI Ok, th code looks good and I don't see an obvious error. Please create a bug report and post the bug number here.

            N Offline
            N Offline
            NightShadeI
            wrote on last edited by NightShadeI
            #5

            @Christian-Ehrlicher Hi Chris, appreciate it. Unfortunately the provided link looks broken and provides me with a 404 not found

            edit: Just created one manually, please find here : QTBUG-112512

            Christian EhrlicherC 1 Reply Last reply
            0
            • N NightShadeI

              @Christian-Ehrlicher Hi Chris, appreciate it. Unfortunately the provided link looks broken and provides me with a 404 not found

              edit: Just created one manually, please find here : QTBUG-112512

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @NightShadeI bugreports.qt.io

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              N 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @NightShadeI bugreports.qt.io

                N Offline
                N Offline
                NightShadeI
                wrote on last edited by
                #7

                Yup can confirm this one is created here 🙂

                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