Results 1 to 10 of 10

Thread: How can I prevent audio application to abort?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How can I prevent audio application to abort?

    Quote Originally Posted by davidlamhauge View Post
    My problem is that my code works the way I want - except from the fact that it crashes the program...
    So it doesn't work the way you want

    I don't know how to "schedule" my "sound playback", but maybe it is here that I should use signals and slots?
    The simplest way I know is to use QQueue or equivalent. The when you get signalled, check if the user currently presses the key to play the next sound and if so, take the next element from the queue.

    And when you write "... start another note", is that a thread? or?
    How do I "queue a series of sounds"? I don't use phonon, but maybe it is a possibility anyway...
    A lot to think about.
    Similar to:

    Qt Code:
    1. struct MouthEntry {
    2. const QString soundPath;
    3. const QString mouthPath;
    4. };
    5.  
    6. QQueue<MouthEntry> m_mouthQueue;
    7.  
    8. void enqueueWordToSay(const QString &word) {
    9. for(int i=0;i<word.size();++i) m_mouthQueue = createEntryFromSound(word.at(i)); // this is oversimplified of course
    10. }
    11.  
    12. connect(audioOutput, SIGNAL(stateChanged(...)), this, SLOT(maybePlayNextNote()));
    13.  
    14. void X::maybePlayNextNote() {
    15. if(!iuserWantsNextFrame) { m_playing = false; }
    16. if(m_mouthQueue.isEmpty()) { m_playing = false; }
    17. playNote(m_mouthQueue.dequeue());
    18. }
    19.  
    20. void X::playNote(MouthEntry entry) {
    21. showMouth(entry.mouthPath);
    22. play(entry.soundPath);
    23. m_playing = true;
    24. }
    25.  
    26. void X::keyPressEvent(QKeyEvent *ke) {
    27. if(ke->key() == Qt::Key_Right) { userWantsNextFrame = true; maybePlayNextNote(); return; }
    28. }
    29.  
    30. void X::keyReleaseEvent(QKeyEvent *ke) {
    31. if(ke->key() == Qt::Key_Right) { userWantsNextFrame = false; return; }
    32. }
    To copy to clipboard, switch view to plain text mode 

    etc.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    davidlamhauge (18th December 2013)

  3. #2
    Join Date
    Sep 2010
    Location
    Denmark
    Posts
    28
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 3 Times in 1 Post

    Default Re: How can I prevent audio application to abort?

    Thank a lot!
    I should have guessed that Qt had a QQueue, ready for me
    I'll loook into it, when I come home from work

    David

Similar Threads

  1. QFtp abort()
    By Talei in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2013, 01:48
  2. qt 4.6.3 coredump - sig abort - help!
    By FredB in forum Qt-based Software
    Replies: 0
    Last Post: 26th November 2012, 17:48
  3. How to prevent multiple executables from application
    By jshafferman in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2011, 19:44
  4. Replies: 1
    Last Post: 18th August 2010, 13:39
  5. Replies: 2
    Last Post: 17th April 2009, 22:36

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.