I am having a perplexing difficulty, in that I cannot get my PyQt program to produce any sound. I am able to get sound correctly from the Pi over HDMI using speaker-test and paplay, so I am happy that both ALSA and Pulseaudio are functioning correctly. I have gstreamer1.0 and gstreamer1.0-pulseaudio packages installed. But my PyPi application gives no sound when I issue a QSoundEffect.play() command. I have put the code in its own separate app as follows (warning - requires kill signal to stop once running) and this works fine.

from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtMultimedia import QSound,QSoundEffect
from sys import argv

app = QApplication(argv)



Unfortunately, when I include the same code snippet within my app, I get nothing, and no feedback as to what is going wrong. Can anyone please suggest how I might be able to unravel this?

My app is using the linux-fb framework to write directly to the frame buffer. X is not running. This should make no difference to Qt and as I said, the snippet above works in my environment, just not within my code.

  • run the code in a console ... do you get an error? ... your question should be asked at a linux site
    – jsotola
    Aug 21, 2022 at 16:05
  • I thought it was a specific RasPi problem with the HDMI sound until I decoupled the code for posting as part of the question, and to my suprise it worked, which makes it more of Qt/PyQt question than than a RasPi one., In any event, playing the sound using pygame works flawlessly, and I am therefore inclined to mix and match rather than sticking with Qt, as portability beyond the Pi is something which would be nice, but is definitely beyond the scope of the project.
    – Christi
    Aug 21, 2022 at 19:02


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.