Results 1 to 10 of 10

Thread: How can I prevent audio application to abort?

Threaded View

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

    Default How can I prevent audio application to abort?

    I am programming a lip-sync software for animation.
    I take a .wav file, and split its 44100 samples pr.sec into 25 or 30 equally big chunks, depending on chosen frames pr. sec.
    I have a QTableWidget, where I can enter characters for every frame. Every character is mapped with a picture of a mouth, and when I press SPACE I hear the audio, and see the pictures in sync with the audio. No problems

    When I want to search in the audio, frame by frame, I can do it with the up/down-arrow keys. It works if I press these keys two or three times pr. sec., but if I hold one of the keys down, the application crashes. Why?
    I would like to avoid hacks like sleep-functions, but what should I do?

    Here is the code that plays the active frame.
    Qt Code:
    1. mouthFrame = activeFrame;
    2. QFile audioFil(audioFileName);
    3. if (audioFil.open(QIODevice::ReadOnly)){
    4. int offset = dataOffset + 8 + ((activeFrame - 1) * samplesPerFrame * blockAlign);
    5. audioFil.seek(offset);
    6.  
    7. ba = audioFil.read(i * samplesPerFrame * blockAlign );
    8. audioFil.close();
    9. QBuffer* audioBuffer = new QBuffer(&ba);
    10. audioBuffer->open(QIODevice::ReadOnly);
    11.  
    12. output = new QAudioOutput(format,this);
    13. output->start(audioBuffer);
    14. output->setNotifyInterval(1000/fps);
    15.  
    16. QEventLoop loop;
    17. connect(output, SIGNAL(stateChanged(QAudio::State)), &loop, SLOT(quit()));
    18. connect(output, SIGNAL(notify()),this, SLOT(showMouth()));
    19. do {
    20. loop.exec();
    21. } while(output->state() == QAudio::ActiveState);
    22. output->stop();
    23. audioBuffer->close();
    24. delete output;
    To copy to clipboard, switch view to plain text mode 
    As I said, it works if you're patient...
    Could it be improved?

    David

  2. The following 3 users say thank you to davidlamhauge for this useful post:

    ebirdseystew (18th December 2013)

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.