Results 1 to 3 of 3

Thread: Phonon: Looping, playing multiple sounds at the same time

  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Phonon: Looping, playing multiple sounds at the same time

    Hello,

    while I did get Phonon to loop sound from a wav file, I'm observing in the Visual Studio output window that every time the sound is played, 6 threads appear to started and ended (six!). What I'm doing to play back is this:

    Qt Code:
    1. audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    2. mediaObject = new Phonon::MediaObject(this);
    3. Phonon::createPath(mediaObject, audioOutput);
    4. connect(mediaObject, SIGNAL(aboutToFinish()), SLOT(doTheLoop()));
    To copy to clipboard, switch view to plain text mode 
    then
    Qt Code:
    1. mediaObject->stop();
    2. mediaObject->clearQueue();
    3. mediaObject->setCurrentSource(absPath);
    4. mediaObject->play();
    To copy to clipboard, switch view to plain text mode 
    and in the doTheLoop slot:
    Qt Code:
    1. if (m_loop)
    2. mediaObject->enqueue(*m_loop);
    To copy to clipboard, switch view to plain text mode 

    Why would it use so many threads, and how can I change that?

    Secondly, is it possible to play multiple sounds at the same time?

    Context: Qt 4.8.1, Windows 7 x64/86, Visual Studio 2010

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Phonon: Looping, playing multiple sounds at the same time

    Why would it use so many threads, and how can I change that?
    Why do you care, and why would you want to change that? If Phonon uses multithreading to load DLLs and play sounds, and if your app is able to do this correctly, what difference does it make how Phonon does what it does? Did you consider that perhaps it does this in a threaded way to avoid locking up your app while the sound is playing?

    Secondly, is it possible to play multiple sounds at the same time?
    And why on earth would you want to do that? Unless the currently playing Phonon instance forces exclusive access to the audio, it should be possible to create a second Phonon instance to play the second sound at the same time.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Phonon: Looping, playing multiple sounds at the same time

    And why on earth would you want to do that?
    As the OP explained to me in a PM, you might want to play multiple sounds at the same time in an audio or video mixing app, or in a game. That makes perfect sense to me.

Similar Threads

  1. looping problem in phonon audio player
    By vinayaka in forum Newbie
    Replies: 2
    Last Post: 12th August 2011, 10:04
  2. Replies: 2
    Last Post: 11th April 2011, 10:20
  3. can't get o/p by playing mp3 file in Phonon
    By dibyendu in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2011, 13:09
  4. Playing multiple audio files with Phonon
    By MartinWalter in forum Qt Programming
    Replies: 0
    Last Post: 23rd December 2010, 11:19
  5. Multiple sounds with QSound possible?
    By JimDaniel in forum Newbie
    Replies: 2
    Last Post: 4th October 2007, 20:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.