WAV file with QML SoundEffect audio playback is distorted

94 Views Asked by At

My first go at using SoundEffect with QML, and I'm getting mixed results with no clear understanding of why. I can successfully use QML SoundEffect in user interface within an embedded C++ device. The thing I cannot solve is why some WAV files will play perfectly clear, and some will not.

I'm certain my code is correct...its something about how the audio is interpreted. I cannot share the WAV files I'm using...but here's what's happening:

I have two WAV files:

wav_file1_that_works.wav (which is 83kb)

and

wav_file2_that_does_not work.wav (which is 110kb)

Both of these files play just fine in VLC or Media Player or whatever. But when ran through the QML function to play as a feedback for touch on the device, the first WAV file plays just fine, while the second one does not. It does not appear to be a hardware issue as this same issue comes up exactly the same when working on virtual environment. I'm suspecting there is some limitation to using WAV audio within the QT/QML environment? But I cannot find any limits in the documentation. My only suspicion is the file size, or some other specific sound file requirement.

First I declare the sound link to the file:

SoundEffect {
        id: playSound
        source: "qrc:/wav_file2_that_does_not work.wav"
    } 

Then on the UI event it's played (not the exact code, but the event certainly works like this:

MyUiItem {
     
        onMyUiTouched: {
         
            playSound.play();
        }
    }

and file 1 plays perfectly, and file 2 plays, but with a very distorted scratchy sounds.

I probably don't know enough about how WAV file encoding works, but on the surface both files seems to be encoded correctly.

1

There are 1 best solutions below

0
Cody Dicken On

I solved this by refactoring how the app compiles as my WAV file was getting compressed. So unfortunately this was something I discovered that if I let my enterprise deployment system do its thing it compresses everything including all multi-media unless I apply certain parameters to not compress. And so now this works. Thanks for the help.