×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    19

    Exclamation QML SoundEffect Element is too slow!

    hi,
    i have a mouseArea in my QML file with an onPressed function which calls a mp3 file.
    The mp3 file is playing correctly, but if i touch the mousearea again during it play the file, it's just waiting till the end of the soundfile and plays it again.

    For example: i have a 1 second mp3-file.
    if i push a mousearea 10 times with my finger during a second, the 1 second mp3-file is repeating... 10 seconds!!!
    the sound should appears when i press the mousearea without to wait till the end.

    can anybody help?

    best regards...



    here a short snippet:

    Code:
    MouseArea {
                            id: ma0
                            x: 0
                            y: 0
                            width: 460
                            height: 200
                            onPressed: {
                                            play_click.stop()
                                            play_click.play()
                            } }
    
            SoundEffect {
                     id: play_click
                     source: "res/click.MP3"
                     volume: 1.0
                 }

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: QML SoundEffect Element is too slow!

    Hi

    It is obvious sound playing functionality cannot react immediately on play and stop commands because it runs in a separate ordinary priority thread. I think 1 second is close to that delay but that value is device dependent. You cannot fix that. Alter your app implementation behavior that after mouseArea clicking UI is blocked for 1 second -- such way you eliminate that problem : user presses 10 times during 1 second and then the app goes mad for 10 seconds.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    19

    Re: QML SoundEffect Element is too slow!

    now i try “Qt Game Enabler API”.

    but there is my next problem.
    I integrate the “Qt Game Enabler API” from this site Using the Audio Plugin [projects.developer.nokia.com]

    But on pushing the mousearea i dont hear anything on my device.
    I think i have a “Source location” problem because the QML Audio Test Project [projects.developer.nokia.com] works fine.

    QML Soundeffect Location:
    —————————————
    The source of a QML Soundeffect i get at his
    location: “C:\QtSDK\Projects\PROJECTNAME\PROJECTNAME\qml\PROJECTNAME\res\reload.wav”
    calling in QML: source: “res/reload.wav”

    QML Audio Plugin Location:
    —————————————
    The source of a QML Audio Plugin i get at his
    location: “C:\QtSDK\Projects\PROJECTNAME\PROJECTNAME\qml\PROJECTNAME\res\reload.wav”
    calling in QML: source: “res/reload.wav”

    A Snippet from my PRO file:
    —————————————

    Add more folders to ship with the application, here
    folder_01.source = qml/PROJECTNAME
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    i cant get it work… how i had to declare the source file?
    maybe
    source: “:/audio/reload.wav” = dont work too
    Last edited by whiteF; 2012-07-14 at 10:10.

  4. #4
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: QML SoundEffect Element is too slow!

    Hi

    “:/audio/reload.wav” does not work because this is a reference to record in resource without prefix. It seems your project does not use application resources packaged in qt project resource file (.rsc)

    If you don't use qt resource -- perhaps you have to provide absolute file-path to
    Code:
    AudioBuffer *AudioBuffer::load(QString fileName, QObject *parent)
    via source property

    Try
    Code:
            
    AudioBuffer {
    ...........
                source: Qt.resolvedUrl ("res/reload.wav")
    ..........

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    19

    Re: QML SoundEffect Element is too slow!

    thanks but:

    won't work:
    Code:
    source: Qt.resolvedUrl ("res/reload.wav")
    now i try to integrate that *.wav in a resource file (with the Wizard "Add File" ...):


    Snippet: *.pro file
    Code:
    RESOURCES += \
        MyResources.qrc
    Snippet: MyResources.qrc:
    Code:
    /audio
    --audio/reload.wav
    won't work - no audio - Qt Gameenabler Audio Plugin:
    Code:
            AudioMixer {
                id: mymixer
                absoluteVolume: 1.0
                //enabled: true
    
                AudioBuffer {
                    id: clickSound
                    source: "qrc:/audio/reload.wav"
                    volume: 1.0
                    speed: 1.0
                    //mixer: mymixer
                }
            }
    won't work - no audio - QML Audio Element (Soundeffect):
    Code:
    SoundEffect {
                     id: play_Schuss
                     source: "qrc:/audio/reload.wav"   // incl. "qrc" // excl. Prefix
                     volume: 1.0
                 }
    Code:
    SoundEffect {
                     id: play_Schuss
                     source: "qrc:/audio/audio/reload.wav"   // incl. "qrc" // incl. Prefix
                     volume: 1.0
                 }
    Code:
    SoundEffect {
                     id: play_Schuss
                     source: ":/audio/reload.wav"   // excl. "qrc" // excl. Prefix
                     volume: 1.0
                 }
    Code:
    SoundEffect {
                     id: play_Schuss
                     source: ":/audio/audio/reload.wav"   // excl. "qrc" // incl. Prefix
                     volume: 1.0
                 }
    now i have a resource problem?!!?!?!
    this qt is awesome...
    Last edited by whiteF; 2012-07-16 at 22:03.

  6. #6
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: QML SoundEffect Element is too slow!

    Hi,

    SoundEffect does not work from resource file --- see details in QTBUG-9253 and QTBUG-23831 : SoundEffect element is a wrapper around QSound, which cannot access sound files from Qt Resource File System (Mentioned in the Document) : Note that QSound does not support resources. This might be fixed in a future Qt version.

    As you see nothing is easy on Qt -- if you want to complete your project you have to find a workaround .... sorry

    As for GEnabler demo it is working. Try to substitute demo resources with yours , perhaps you miss something in the implementation.

Similar Threads

  1. SoundEffect element on device
    By vaselli.vittorio in forum [Archived] Qt Quick
    Replies: 2
    Last Post: 2012-05-14, 14:06
  2. Replies: 3
    Last Post: 2012-05-14, 14:05
  3. QML SoundEffect working for anyone?
    By grekker in forum Nokia N9
    Replies: 8
    Last Post: 2011-12-29, 07:55
  4. Replies: 6
    Last Post: 2010-05-03, 21:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×