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 the QSoundEffect will play two sources after I change the source
Forum Updated to NodeBB v4.3 + New Features

why the QSoundEffect will play two sources after I change the source

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 796 Views 2 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.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by
    #1

    Hi
    when I use a QSoundEffect to play different audio files, I find it will play two files after QSoundEffect::setSource().
    e.g.

    QSoundEffect *player = new QSoundEffect ();
    player->setSource(QUrl::fromLocalFile("/1.wav"));
    player->play();
    
    player->setSource(QUrl::fromLocalFile("/2.wav"));
    player->play(); /*play 1.wav then play 2.wav*/
    

    what's wrong with it?

    Regards
    Mihan

    jsulmJ 1 Reply Last reply
    0
    • MihanM Mihan

      Hi
      when I use a QSoundEffect to play different audio files, I find it will play two files after QSoundEffect::setSource().
      e.g.

      QSoundEffect *player = new QSoundEffect ();
      player->setSource(QUrl::fromLocalFile("/1.wav"));
      player->play();
      
      player->setSource(QUrl::fromLocalFile("/2.wav"));
      player->play(); /*play 1.wav then play 2.wav*/
      

      what's wrong with it?

      Regards
      Mihan

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mihan said in why the QSoundEffect will play two sources after I change the source:

      QSoundEffect

      You're adding second source just after staring playing, right? So, I would say it does exactly what you tell it to do.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      MihanM 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Mihan said in why the QSoundEffect will play two sources after I change the source:

        QSoundEffect

        You're adding second source just after staring playing, right? So, I would say it does exactly what you tell it to do.

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by
        #3

        @jsulm
        Yes, I alse find it will play with different volume after QSoundEffect::setVolume(),and the voice is very large even I just set it 0.15 ( when the volume is 0.1 ,the voice is so normal, but when it's 0.15 , the voice seems to be the biggest)

        is it about platform or Qt version? I'm using Qt 5.6.2 on IMX6DL kernel 4.1.15

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

          Hi,

          As @jsulm wrote, it's doing exactly what you are asking it to do. You load a file, call play, load a different file, call play again. That's exactly what you are hearing.

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

          MihanM 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            As @jsulm wrote, it's doing exactly what you are asking it to do. You load a file, call play, load a different file, call play again. That's exactly what you are hearing.

            MihanM Offline
            MihanM Offline
            Mihan
            wrote on last edited by Mihan
            #5

            @SGaist @jsulm
            Yes I know that.
            It sounds like as follow:
            无标题.png
            Maybe the pulseaudio in my device is too old (version 8.0, the maintainer said should update it).

            jsulmJ 1 Reply Last reply
            0
            • MihanM Mihan

              @SGaist @jsulm
              Yes I know that.
              It sounds like as follow:
              无标题.png
              Maybe the pulseaudio in my device is too old (version 8.0, the maintainer said should update it).

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mihan Why don't you wait until first file actually finished playing before starting second one?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              MihanM 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Mihan Why don't you wait until first file actually finished playing before starting second one?

                MihanM Offline
                MihanM Offline
                Mihan
                wrote on last edited by Mihan
                #7

                @jsulm
                Sure I have waited the first file finished.
                Even I use different QSoundEffect to play different file, it still remains a little data in the latest time.

                Also if I just change the volume for the same source, it still play audio like above ( the second time will play with different volume at the beginning).

                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