Has anyone had any luck with the sound library on the pi 0?

Hello everyone
According to https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/pi-zero-pwm-audio
there is a way to play audio out of the pi 0. I tried to reproduce it, followed all the instructions, and even though the monitor window on the pi tells me the audio is playing, I am not hearing anything. So I thought, mmmhhh I am pretty good with Processing so let me see if I can write a simple sketch on the pi to see if this is actually feasible.
Well the Processing compiler tells me that “Sound” is not a class, that it does not recognize commands like “void” or that the void draw () is missing a ; (when I know it is not)
Hence now I am wondering if there is not a larger issue where the library did not download properly or what?
Has anyone had similar errors and how did they solve it ?

1 Like

@gwenn A lot of the parts on the Raspberry Pi are still in some level of flux, as the software stack matures. On all versions but the Pi Zero, audio playback works sufficiently okay - e.g. with Processing’s Sound library (which you can find, with examples, in the Contributions Manager). But it seems the (PWM-based) sound is at least not officially supported on the Zero, since it doesn’t have a the jack (or the internally connected header pins exposed).

I know, USB ports are at an abolute premium on this device as well, but my suggestion would be to simply get a supported, cheap USB sound card. This way you’ll have clean(er) playback, and also a handy microphone port.

1 Like

Hi Gottfried, thanks for your reply. OK but how is the USB sound card going to fix the issues with the Processing library? My issue at the moment is that the Processing compiler does not recognize many of the standard function in Processing (void, etc), when used on the pi 0.

Hi @gwenn - Processing on the Pi Zero should behave exactly the same as on another board or platform. When you’re seeing an error complaining that Sound is not a class, this would indicate to me that the Sound library is perhaps not installed? (You find it for download in the Contributions Manager.)

Perhaps you could try some of the examples that come with the Sound Library on their own, to ensure that this works. Compilation errors like this shouldn’t have any connection to which hardware you have connected, but they might point to something else (libraries, sketch) being amiss.

Thanks Gotfried. I am going to re-install the library then (or perhaps install it) because I had troubles installing Processing (initially) hence perhaps the library did not get installed in the end? I have tried the basic sound example and I am still getting compiler errors

Thanks again


Oh duh! I overlooked this when I installed P5 on the pi. That would explain everything (so dumb from me) “The Video and Sound libraries need to be downloaded through the Library Manager.”


Hi all, me again
The sound library is working fine on the pi, but I am getting an issue (and I noticed someone on GitHub having a similar recent issue, but as of now that thread is unresolved)
I am trying a super simple play back sketch but when I try to load a three minutes long uncompressed wave file I get an
ArrayIndexOutOfBondsException: 3 Message from the Processing compiler. I am guessing it is more of a java issue, but I don’t know how to fix it. Is there a maximum file size for Audio on the Pi ? (I am guessing not since I am using a 16GB simcard for storage) Any ideas what this problem could be?
Many thanks