I searched for “audio” and got no results. So, I’m wondering; does Klipper/fluidd or Mainsail support using the Pi 4’s audio out port?
It might seem like a trivial request, but I really do find the ability to play sound at the end of a print job very helpful, so I would love to be able to do it with Klipper.
I was able to play some sound when I was running on a Creality 4.2.7 board, but the SKR 1.4 Turbo I’m now using doesn’t seem to have a beeper pin (maybe I’m just missing it?).
Anyway, it got me thinking that maybe the better option would be to play sound from the Pi itself, preferably out the audio port. That way, hopefully, I could attach an amplified speaker and, maybe, play higher quality sound.
I’m not worried about CPU usage or interfering with actual printing, because I would only be playing sound at the end of the print job.
The Raspberry Pi audio out is a bit different than the beepers on those 12864 displays. The Pi audio port works off a linux audio subsystem just like your speakers on your computer. This subsystem takes an input stream of encoded audio and then uses PWM to output it into the Audio jack.
Your standard beepers emit a tone at whatever frequency you PWM them at.
So when the end-print thing happened, the gcode would have a “beep” encoded in the gcode which is little more than a bit of voltage on the beeper pin for an amount of time.
It is possible to use the RPI’s audio port via the Klipper host service but it is a pain in the ass to make it work and definitely not a “supported” thing. There may or may not be a gcodesound.py file somewhere on my personal Klipper repo.
Thanks very much for the reply: very informative. As I mentioned, the beeping works fine with the Creality 4.2.7 board, but not the SKR 1.4 Turbo. Because of this difference between control boards I was thinking it might be useful to move the sound function to the Pi, so it would be independent from the control board. But, AFAIK, the Pi doesn’t have a buzzer onboard. I guess it would come down to hooking up a buzzer to the Pi’s GPIO pins, but would the M300 macro I found online be able to work with that buzzer? I am not sure how the pin names would work. Can a macro in printer.cfg even address pins on the Pi?
Hah, I see from a quick search that you are the author of a python sound module. It also seems you found it somewhat clunky & weren’t sure you would continue with it.
It seems that it may be more trouble than it’s worth. Thanks again for the feedback.