Saving the Emotiv EPOC affective suite data in a text file

// Based on the ProcessingEpocOsc1 example by Joshua Madara, available at
// hyperritual.com/blog/processing-epoc-osc/
// Modified by Dorothea Kalogianni and Zechao Alvin
//Saving the Emotiv EPOC affective suite data in a text file
import oscP5.*;
import netP5.*;
float excitement;
float boredom;
float engagement;
float frustration;
float meditation;
OscP5 oscP5;
PrintWriter output;

void setup() {
oscP5 = new OscP5(this, 7400);
// Create a new file in the sketch directory
output = createWriter(“testing.txt”);
}

void draw() {
int m = millis();
//output.print(m,”excitement=”++ “,”+);
output.println(“time=” + hour()+”:”+minute()+”:”+second() + ” ” + “,”);
output.println(“excitement=” + excitement + ” ” + “,”);
output.println(“engagement=” + engagement + ” ” + “,”);
output.println(“frustration=” + frustration + ” ” + “,”);
output.println(“meditation=” + meditation + ” ” + “,”);
output.println(“boredom=” + meditation + ” ” + “,”);
}

void oscEvent(OscMessage theOscMessage) {
// check if theOscMessage has an address pattern we are looking for
if(theOscMessage.checkAddrPattern(“/AFF/Excitement”) == true) {
// parse theOscMessage and extract the values from the OSC message arguments
//excitement = ceil(theOscMessage.get(0).floatValue()*255);
excitement = theOscMessage.get(0).floatValue();
} else if (theOscMessage.checkAddrPattern(“/AFF/Meditation”) == true) {
meditation =theOscMessage.get(0).floatValue();
}
if(theOscMessage.checkAddrPattern(“/AFF/Engaged/Bored”) == true) {
// parse theOscMessage and extract the values from the OSC message arguments

engagement = theOscMessage.get(0).floatValue();
boredom = 1-engagement; //to seperate boredom from engagement

} else if (theOscMessage.checkAddrPattern(“/AFF/Frustration”) == true) {
frustration = theOscMessage.get(0).floatValue();
}
}

void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit(); // Stops the program
}

Download file EMOTIV_data