This Processing sketch demonstrates interaction with the Emotiv EPOC‘s Affectiv™ data. The five circles grow or shrink and brighten or dim according to the values (between 0 and 1) of “Engaged/Bored,” “Excitement,” Excitement Long Term,” “Meditation,” and “Frustration.” Below is a video showing the circles changing over time (sped up 3×). See the article, “Processing + EPOC via OSC,” for more general information about interfacing the EPOC and Processing.

Here is an EmoScript for EmoComposer, to test the interaction without needing the headset. See the Emotiv EPOC SDK guide for more about that.

Here is the code (looking at it a year later, it could stand to be refactored):

 * AffectCircles
 * by Joshua Madara,
 * demonstrates Processing + Emotiv EPOC via OSC
 * five circles grow and shrink in response to five
 * Affectiv values from EPOC: engagement/boredom; excitement; 
 * long-term excitement; meditation; frustration.
import oscP5.*;
import netP5.*;

public float engBor = 0; // Engaged/Bored
public float exc = 0; // Excitement
public float excLon = 0; // Excitement Long Term
public float med = 0; // Meditation
public float fru = 0; // Frustration

OscP5 oscP5;

void setup() {
  size(480, 360);
  /* start oscP5, listening for incoming messages on port 7400
  make sure this matches the port in Mind Your OSCs */
  oscP5 = new OscP5(this, 7400);
  // plug the OSC messages for the Affectiv values
  oscP5.plug(this,"updateExcLon","/AFF/Excitement Long Term");

void draw() {
  // draw fading background
  fill(0, 10);
  rect(0, 0, width, height);
  // draw circles
  drawCircle(engBor, 1); // circle 1: Engaged/Bored
  drawCircle(exc, 2); // circle 2: Excitement
  drawCircle(excLon, 3); // circle 3: Excitement Long Term
  drawCircle(med, 4); // circle 4: Meditation
  drawCircle(fru, 5); // circle 5: Frustration

void drawCircle(float affVal, int circleNo) {
  stroke(color(round(map(affVal, 0, 1, 0, 255))), 10);
  float diam = map(affVal, 0, 1, 1, width/5);
  ellipse((width/6)*circleNo, height/2, diam, diam);

public void updateEngBor(float theValue) {
  engBor = theValue;

public void updateExc(float theValue) {
  exc = theValue;

public void updateExcLon(float theValue) {
  excLon = theValue;

public void updateMed(float theValue) {
  med = theValue;

public void updateFru(float theValue) {
  fru = theValue;

6 Replies to “AffectCircles”

  1. Hi Joshua,

    I don’t know if you’ll see this message as we are now a few years later, but I was wondering if you still used the Emotiv and if the sketch you give here still works like a charm on your machine?
    I am currently trying to get access to the /AFF/ functions of the headset in processing too (Meditation, Engaged/Bored, …) but the update functions do not even get called. Whereas when I try with the /EXP/ ones (WINK_LEFT, …) everything works perfectly.. So I’m trying to understand why and how to troubleshoot it!
    Thanks a lot :)

    1. Hello, Marie. I have not done anything with the EPOC in some time, but several people have mentioned here that Mind Your OSCs is not working properly with the latest version of the Emotiv Control Panel. I am not sure if that is the reason for the problem you are having. I have a dev license for the Insight and wish to make something like Mind Your OSCs for it, but I have too many other projects ahead of that. Sorry I could not be more helpful. Best of luck!

    1. Hi, Noah. In the setup() of the sketch, you’ll see


      — this sends the value from the Affectiv/Frustration measurement to the updateFru function. The bit you quoted defines what the function does with that value — it just updates the global variable fru. Make sense?

Leave a Reply