ControlP5 buttons response, how to make it faster for musical applications?

edited June 2014 in Android Mode

Hello everyone, my name is Emiliano and I am creating a project that controls a Raspberry Pi running pure data through OSC via Wi Fi through an app created with Processing for Android.

Here its a little video demo,

The button are made with ControlP5 Library. I am having some latency, and at some point, when you press a key too fast, it will lose some hits.

The codes flows like this (will only paste what is realted to the buttons);


// I Import the libraries

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

//Then in setup, I define all my buttons like this

gui.addButton("C")
   .setPosition(cX,cY)
   .setSize(bWidth,bHeight)
   .setValue(0)
   .setColorForeground(0xffED4D4D)
   .setColorBackground(0xffED4D4D)
   .activateBy(ControlP5.PRESSED);
   ;

// I define its method outside setup.

public void C(int value){
// This is the place for the code, that is activated by the buttonb
  println("C pressed");
  OscMessage myOscMessage = new OscMessage("/noteon");
  myOscMessage.add(48 + (octave*12));
  OscP5.flush(myOscMessage,myRemoteLocation);
}

// And then I send the note off when "mouse" is released.

void mouseReleased() {
  println("Note Off");
  OscMessage myOscMessage = new OscMessage("/noteoff");
  OscP5.flush(myOscMessage,myRemoteLocation);
}

I have already tried bangs and buttons and found no diference, even tried a really simple code


import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;
int send = 0;

void setup(){
size(displayWidth,displayHeight);
myRemoteLocation = new NetAddress("192.168.1.43",10000);
}

void mousePressed(){
  send = 1;
}


void mouseReleased() {
  send = 2;
}

void draw(){
  background (0);
  if (send == 1){
     OscMessage myOscMessage = new OscMessage("/noteon");
     myOscMessage.add(50);
     OscP5.flush(myOscMessage,myRemoteLocation);
  }
  if (send == 2){
      OscMessage myOscMessage = new OscMessage("/noteoff");
      OscP5.flush(myOscMessage,myRemoteLocation);
  }
  send = 0;

}

And it still feels laggy.

Any idea on how to improve this ?

Thank you for your time.

Emiliano

Sign In or Register to comment.