We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hello everyone i need your help i'm this close to freak out. So, i am using a Neurosky Mindwave to send brain waves' data to processing and use the data to animate shapes (a shape for each category of wave). For example the delta wave's value is connected to a circle and its radius bigger when data waves increase. The thing is that the device mesures once per seconde thus the shape changes its size but not in a smooth way (1frame/sec). I thought i should use "easing" but to use it i need an oldValue and newValue and this is where i freak out, i don't manage to save a value at a time t and compare it to the value from t+1
sorry if it's unclear, here is the code
thanks a lot for your help !!!
import neurosky.*;
import java.net.ConnectException;
ThinkGearSocket neuroSocket;
// WAVES CATEGORY
int delta = 0;
int theta = 0;
int low_alpha = 0;
int high_alpha = 0;
int low_beta = 0;
int high_beta = 0;
int low_gamma = 0;
int mid_gamma = 0;
int a = 25;
// RADIUS OF EACH CIRCLE
float radius1 = 0;
float radius2 = 0;
float radius3 = 0;
float radius4 = 0;
float radius5 = 0;
float radius6 = 0;
float radius7 = 0;
float easing = 0.01;
void setup()
{
size(1000, 1000);
ThinkGearSocket neuroSocket = new ThinkGearSocket(this);
try
{
neuroSocket.start();
}
catch (ConnectException e) {
e.printStackTrace();
}
finally {
}
smooth();
noStroke();
}
void rawEvent(int[] rawdata)
{
//println(rawdata);
}
void eegEvent(int delta, int theta, int low_alpha, int high_alpha, int low_beta, int high_beta, int low_gamma, int mid_gamma)
{
radius1 = log(delta)*a;
radius2 = log(theta)*a;
radius3 = log(low_alpha)*a;
radius4 = log(high_alpha)*a;
radius5 = log(low_beta)*a;
radius6 = log(high_beta)*a;
radius7 = ((log(low_gamma) + log(mid_gamma))/2)*a;
println("delta: "+log(delta));
println("theta: "+log(theta));
println("low_alpha: "+log(low_alpha));
println("high_alpha: "+log(high_alpha));
println("low_beta: "+log(low_beta));
println("high_beta: "+log(high_beta));
println("gamma: "+log(low_gamma + mid_gamma)/2);
println("fps: "+frameRate);
}
void stop() {
neuroSocket.stop();
super.stop();
}
void draw()
{
background(0);
translate(500, 0);
ellipse(0, 111, radius7, radius7); //PURPLE
fill(240, 46, 255, 127);
ellipse(0, 222, radius6, radius6); //LILA
fill(189, 94, 227, 127);
ellipse(0, 333, radius5, radius5); //BLUE
fill(0, 0, 255, 127);
ellipse(0, 444, radius4, radius4); //GREEN
fill(0, 255, 0, 127);
ellipse(0, 555, radius3, radius3); //YELLOW
fill(255, 249, 64, 127);
ellipse(0, 666, radius2, radius2); //ORANGE
fill(255, 96, 64, 127);
ellipse(0, 777, radius1, radius1); //RED
fill(255, 0, 0, 127);
}
Answers
I don't know if you prefere such a way, but here's a sketch:
Imagine that mousePressed is your eegEvent it just generates a random number whenever you press a mouse, instead of data from your super mind-reading helmet. This is where new radius is set and then, you need to increase or decrease radius value, untill it would be equal to new value. Here, i just use
+=1
, however, you can use any other algorithm, you'll need to play with this to make it work for you anyway.Thanks a lot !!! I'll try this and get back to you ! Have a great evening !!
it worked like a charm thanks again