Processing 3 running slow on Pi4

I recently got a 4GB Ram Pi4 to build a sampler pad to use for performances. After a fresh install of Raspian Buster (using NOOBS) I downloaded the latest Processing (ARM) to the pi, however I immediately began experiencing choppiness in the IDE from things as simple as scrolling. I then tried to run some of the example sketches from the Sound library, and I experience what seems like low frame rate and extremely choppy audio. I am wondering if there is some recommended setup for the pi that I may have missed. The pi is connected through HDMI to a 1980x1080 display, and I have tried playing the audio through HDMI, an external soundcard, and the 3.5 mm jack. I can provide any video, screenshots, or output that may help diagnose the issue.

1 Like

sorry i only have a RPI 3B+
and yes a Raspberry Pi is a small/cheap computer

i use

2019-09-26-raspbian-buster-full.zip

install processing 3.5.3 with

curl https://processing.org/download/install-arm.sh | sudo sh

and use it via HDMI or remote VNC

sudo raspi-config 7 advanced options / A3 memory split / 128 MB


and yes , like the start of processing is painful slow

my own stresstest/info

float rset=120, r;
int x = 0;
int w = 400;
int h = 200;
int grid=20, many = grid*grid;
boolean stressenable=true;

void settings() {
  size(w, h); // default use JAVA2D 
  //  size(w, h,FX2D);
  //  size(w, h,P2D);
  //  size(w, h,P3D);
}

void setup() {
  frameRate(rset);
  background(200, 200, 0);
  numinfo();
  sysinfo();
  println("\nstresstest ( "+grid+"*"+grid+" = "+many+" ) points, [+][-] grid +-5" );
}

void draw() {
  surface.setTitle("SYS INFO set "+rset+": "+ nf(r, 0, 1)+" FPS" );
  if ( stressenable ) stress();
  r = frameRate;
  if ( r > 30 )      stroke(0, 200, 0); 
  else               stroke(200, 0, 0);
  line(x, height-2, x, height-2-r);            // FPS graph
  x++;
  if ( x > width ) { 
    x = 0; 
    background(200, 200, 0);
  }
}

void stress() {
  push();
  for ( int i=0; i<grid; i++) {
    for ( int j=0; j<grid; j++) {
      stroke(random(255), random(255), random(255) );
      point(5+i, 5+j);
    }
  }
  pop();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System     : " + System.getProperty("os.name") + "  " + System.getProperty("os.version") );// + "  " + System.getProperty("os.arch") );
  println( "JAVA       : " + System.getProperty("java.home")  + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL     : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home  : " + System.getProperty("user.home") );
  println( "user.dir   : " + System.getProperty("user.dir") );
  println( "user.name  : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath   : " + dataPath("") );
  println( "dataFile   : " + dataFile("") );
  println( "frameRate  : target "+nf(rset, 0, 1)+" actual "+nf(r, 0, 1));
  println( "canvas     : width "+width+" height "+height+" pix "+(width*height));
}

void numinfo() {
  println( "__NUM INFO :");
  println( "byte     "+Byte.SIZE+  " bit | min: "+Byte.MIN_VALUE+   "\t\t\t max: "+Byte.MAX_VALUE);
  println( "short   "+Short.SIZE+  " bit | min: "+Short.MIN_VALUE+  "\t\t\t max: "+Short.MAX_VALUE);
  println( "int     "+Integer.SIZE+" bit | min: "+Integer.MIN_VALUE+"\t\t max: "  +Integer.MAX_VALUE);
  println( "long    "+Long.SIZE+   " bit | min: "+Long.MIN_VALUE+   "\t max: "    +Long.MAX_VALUE);
  println( "float   "+Float.SIZE+  " bit | min: "+Float.MIN_VALUE+  "\t\t\t max: "+Float.MAX_VALUE);
  println( "double  "+Double.SIZE+ " bit | min: "+Double.MIN_VALUE+ "\t\t\t max: "+Double.MAX_VALUE);
}

void keyPressed() {
  if ( key == 's' ) stressenable = ! stressenable;
  if ( key == '+' ) {
    grid +=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
  if ( key == '-' ) {
    grid -=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
}

give me after a few seconds 70FPS
key [s] without stress i see 120FPS

also it is known that on bigger canvas settings it get slower as you might be used from a
PC ( with 10 times the prize )

so for compare ( like FPS ) we need to run same code.


for the SOUND,
did you install SOUND 2.2.3 lib,
( what is mostly not working here )

or Minim,… what example?

like Minim / Audioplayer / loop / key [l]
sounds same for my ( play via HDMI cable to a small TV )
like from my PC ( same connection )

you say " choppy " like bad sound quality or like not play smooth?


so my point is that it is not clear if you are disappointed by your first RPI
or if there are real issues / esp. processing issues?

how about when you run browser and YouTube video, same sound problem?

1 Like

I have a RaspberryPI4 (4G ram), that I use to test picrate a ruby implementation of processing (using JRuby). I haven’t tried running the processing ide (using instead geany as my ide). If you haven’t already done so I recommend you install latest updates:-

  1. sudo apt-get update
  2. sudo apt-get dist-upgrade

I also suggest using FakeKMS option, for video I use the latest processing video library see also USB Camera Capture on RaspberryPI. For my application I use Debian Buster open-jdk8 (the processing download includes a modified oracle jdk8). You should bear in mind processing was designed with RasberryPI3 in mind.

1 Like

did you try install

and run example?
( just try first time and its useless here RPI3.
must be a reason why its not included )

Yeah sound library useless here on RaspberryPI4, get warning of amplitude of zero means this sound is not audible now. Sounds from web eg BBC Radio 3 absolutely fine, so its not the PI.

2 Likes

KII, I installed the SOUND library. I tried running the examples included, to test basic soundfile playback. I will try to run the test and see what comes up.

Are you saying you are having better luck with Minim?

Monkstone thank you, I will make sure to install the latest updates. I have also noticed the “amplitude is zero” warnings. And yes, other audio from Chromium is absolutely fine. The Processing user experience overall seems to be

I took the MicroSD card from my RPI4 and put it into my RPi2. Everything boots up fine, but when I run processing and try to run the sketch things are even slower than on the RPI2.

1 Like

-0- you installed a sound library, but not tell,
lucky i exactly try that ( via HDMI )
as i usually play ( via VNC ) no sound.

-1- MINIM 2.2.2 run well on both BUSTER Images ( on RPI3 )

-2- typing not understandable,

    • user experience ?
    • RPI2 slower as RPI2 ?

-3- did you try my stress code and can you give the 2 FPS numbers ( with & without stress )
so we see your system is ( should be ) faster as my RPI3 ( 70/120 )

minim also plays well on my RaspberryPI4 with my picrate gem see screenshot (sketch run from geany):-

1 Like

I ended up trying out the Beads library for Processing and things are running very smoothly! The Beads library also offers a larger toolkit for managing many samples, although it took me a couple hours of playing with it to really understand out to connect things together. Sound is playing out of my RPi4 without any hiccups. Thank you for the help everyone

1 Like

-0- I am referring to the standard Processing Sound library, which is called just that. https://processing.org/reference/libraries/sound/index.html

-1- thank you, I was going to try this if the Beads library did not work.

-2- typing not understandable,

    • user experience ?

Sorry it looks llike I left out the end of that sentence. The User Experience in processing on the RPi4 is still very laggy.

    • RPI2 slower as RPI2 ?

This was a mistake, I meant that the RPI2 was slower than the RPI4,

@kll @klitsner
OK I think I’ve got a fix, pulseaudio is not installed by default:-

sudo apt-get install pulseaudio
# and it might be an idea to install gstreamer plugin whilst you are at it.
sudo apt-get install gstreamer1.0-pulseaudio
 

Sound library now working for me on raspberrypi4

2 Likes

thats awesome! i am away from home but I will definitely try this when I am back. Although now that i have started using the beads library I may stick with it, it seems very versatile. I think i will try to compare performance and see if one runs better thn the other

one other trick is to put /tmp and /var/log in tmpfs (ram) that cuts R/W cycles on the Sd card way down and improves performance. By default that is not setup in the /etc/fstab file.

1 Like

i’m struggling with slow performance too. Even if is not an audio project. Just testing a bouncing ball and particle system and i’ve seen framerate of 5 or 7 fps.
Even a really really simple sketch.

if you post your code i could try it on RPI3 and might find small things to improve,
but i just guess you run your

in fullscreen?

yes but even in small window like 600x600. Does not change much.
The simplest sketch on earth something like:

void setup(){
fullScreen();
}
void draw(){
ellipse(mouseX,mouseY,20,20);
}

it was meant just to see how it works on raspberry pi… and the results were disappointing

So i’ve made some test with the frame rate. At fullscreen i grt around 6fps, at 800x800 i get 19 fps,
And 40 at 400x400.
Is Raspberry Pi really so limitated?

I thing there must be something wrong. With my PICrate gem (processing in ruby which usually runs a bit slower than vanilla processing) my fibonaacci_sphere.rb sketch runs at at least 11 fps 1024 * 760 and 2000 points (updated every frame).

yeah, that’s why i’m here.
I’ve seen in the manual that in the settings i can toggle the 4k screen support if i attach an HD screen and this could improve performances. I’ll test that.

Ok so seems there is no such thing in the settings. Maybe is something that appear only if you connect a 4k screen.

So, is there any way to perform a full screen sketch with a decent framerate?

1 Like