Results 1 to 19 of 19

Thread: Using QSound::play("...") not working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Using QSound::play("...") not working

    Hi all,

    I have developed a small program which will play a tone on any Key press. Now when I runt he application on desktop it works fine. But when I cross compile it for my device and run the application there no sound output is achieved. I have used QSound:lay("..."); for playing the sound. The file is a .wav file. It gives the following error:

    get volume of audio device failed
    Floating point exception

    Any idea what the problem might be anybody??? I have read that QSound directly accesses the /dev/dsp on an embedded device. When I use aplay on my device the tone is played fine.

    Edit: Do I need to put any specific library on the device. Right now I have put three as per my requirement which are QtCore QtGui and QtNetwork.

    Help soon.

    Charvi Mehta.
    Last edited by Charvi; 31st March 2012 at 14:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QSound::play("...") not working

    What platform are you targetting? On Unix QSound requires NAS. Better use Phonon instead.
    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.


  3. #3
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    Can't try with phonon right now. But what I assume is I will need to put the QtMultimedia library on my embedded device before I run the program. Is that it? Do I need anything else to run a program that uses the phonon?


    Yes my embedded device uses the Unix platform.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QSound::play("...") not working

    QtMultimedia nad Phonon are two separate things. Both will require you to have a proper version of GStreamer though.
    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.


  5. #5
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    okay. But why isn't there anything which can directly access the /dev/dsp and work?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QSound::play("...") not working

    You can open /dev/dsp with QFile and stream data to it if you want.
    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.


  7. #7
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    okay I used a workaround due to lack of time to experiment. I used the system command from within Qt and used aplay utility.

    Now I get a key press sound on every keypress which I have handled in the event filter; because there I use the system command. But what should I do for the keys which are not handled by the event filter and which are internally handled by Qt. Like I have used a QScrollArea. The scroll bar navigation takes place with the up and down arrow keys. This is internally handled by Qt and hence no sound is played here. Is there anyway I can play sound here also? Ofcourse there is a way. Can anybody point out please.

    Please reply.
    Last edited by Charvi; 3rd April 2012 at 08:19.

  8. #8
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    Please reply.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QSound::play("...") not working

    Install an event filter on the application object and intercept key events there.
    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.


  10. #10
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    No but then I will have to write the code for all the basic key press events also. That will be tedious and not desirable. Like then I will have to write event for scrolling; that's not going to be as smooth as the internal handling. It will also increase the lines of code.

    Reply soon.
    Last edited by Charvi; 3rd April 2012 at 10:37.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QSound::play("...") not working

    Quote Originally Posted by Charvi View Post
    No but then I will have to write the code for all the basic key press events also.
    No, you won't.
    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.


  12. #12
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Using QSound::play("...") not working

    Could you please give me an example or explain in more detail.

    "Install an event filter on the application object and intercept key events there. "

    How exactly?

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 21:46
  2. Replies: 3
    Last Post: 15th February 2010, 17:27
  3. Replies: 3
    Last Post: 26th April 2009, 17:54
  4. Replies: 3
    Last Post: 8th July 2008, 19:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.