Why does QSoundEffect play sounds poorly unlike QMediaPlayer?
-
wrote on 2 Apr 2023, 07:13 last edited by
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
-
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.
-
Please show your code.
wrote on 2 Apr 2023, 12:04 last edited byAlright 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(); }
-
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.
-
@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.
wrote on 2 Apr 2023, 21:56 last edited by NightShadeI 4 Feb 2023, 22:03@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
-
@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
-
wrote on 3 Apr 2023, 09:35 last edited by
Yup can confirm this one is created here 🙂
7/7