How to install sound library so that I can use properly on raspberry pi 4?

Hello everybody,

I am new with raspberry pi , trying to use the “basic” sound library on my raspi 4. I don’t want to change to beads or minim (both working, also p5.js works), because the codes are all done and working on windows system with processing.

E.g. when I use the sketch below, there is no error, but also no sound only some choppy noise on the speakers (almost not noticeable). I Installed the library through processing 3.5.3, sound 2.2.3

import processing.sound.*;
SoundFile soundfile;

void setup() {
size(640, 360);
background(255);
soundfile = new SoundFile(this, “vibraphon.aiff”);
println(“SFSampleRate= " + soundfile.sampleRate() + " Hz”);
println(“SFSamples= " + soundfile.frames() + " samples”);
println(“SFDuration= " + soundfile.duration() + " seconds”);
soundfile.loop();
}

void draw() {
float playbackSpeed = map(mouseX, 0, width, 0.25, 4.0);
soundfile.rate(playbackSpeed);
float amplitude = map(mouseY, 0, width, 0.2, 1.0);
soundfile.amp(amplitude);
float panning = map(mouseY, 0, height, -1.0, 1.0);
soundfile.pan(panning);
}

I was looking around for two weeks in forums, but couldn’t find anything that helped me. Any suggestions? Does anybody know a reliable way to use soundfile?

@bernd Could be you’ve not installed pulse-audio, which seems to be required by the sound library. Here’s what you should see when you run alsamixer in a terminal. I believe it gets installed by default on ManjaroARM (64 bit), but probably not on RaspberryPI OS (formerly Raspbian).

Card: PulseAudio                                     F1:  Help               │
│ Chip: PulseAudio                                     F2:  System information │
│ View: F3:[Playback] F4: Capture  F5: All             F6:  Select sound card  │
│ Item: Master                                         Esc: Exit   

If installed the pulseaudio-volume control looks like this with sketch running:-
Pulse

Thank you for this reply, fast as lightning^^. That sounds interesting and I will try it these days, in the meantime in my desperateness I actually changed the code to beads library, it works fine, so I am a bit worried if I install pulseaudio, can it affect the now working system negatively? That is what my alsamixer is telling me, looks like no pulseaudio, I will give it a try later, Thanks anyway!
Screenshot_20200805_225600 Screenshot_20200805_225719 Screenshot_20200805_225812 Screenshot_20200805_225916

By the way, can anybody recommend a reliable pusleaudio installation workflow?
what I was checking, most of them seem to be pretty tricky?

I installed pulseaudio, also shown in alsamixer, but now there is no sound anymore, maybe a problem with the latest raspian? I will leave it with beads, anyway thanks a lot for your efforts^^