Why does QSoundEffect play sounds poorly unlike QMediaPlayer?
-
I'm trying to play a very short sound (definitely less than a second , maybe 0.2 seconds)
I notice the sound is clear and crisp from QMediaPlayer, but not from QSoundEffect in Qt6 using C++
The start or end of the sound gets cutoff in QSoundEffect which sounds counter-intuitive given its optimised for things like this
I notice many applications to play audio files have this issue, but some play it really smoothly just like QMediaPlayer
My operating system is Windows 10
-
Please show your code.
-
Alright will share the code here, hadn't initially intended to provide it because I don't think it will be useful , and more fishing for an answer as to why the two are giving different results. Also I cannot provide the wav file by law, nonetheless, here is the relavent code:
int main(int aArgc, char *aArgv[]) { QApplication myApplication{aArgc, aArgv}; QMediaPlayer* myMediaPlayer = new QMediaPlayer; myMediaPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav")); QAudioOutput* myMediaAudioOutput = new QAudioOutput; myMediaAudioOutput->setVolume(1.f); myMediaPlayer->setAudioOutput(myMediaAudioOutput); QSoundEffect* myEffectPlayer = new QSoundEffect{}; myEffectPlayer->setSource(QUrl::fromLocalFile("path/to/file.wav")); myEffectPlayer->setVolume(1.f); myEffectPlayer->setLoopCount(1); // myEffectPlayer->play(); myMediaPlayer->play(); return myApplication.exec(); }
-
@NightShadeI Ok, th code looks good and I don't see an obvious error. Please create a bug report and post the bug number here.
-
@Christian-Ehrlicher Hi Chris, appreciate it. Unfortunately the provided link looks broken and provides me with a 404 not found
edit: Just created one manually, please find here : QTBUG-112512
-
-
Yup can confirm this one is created here 🙂