BCI – OSC
Open Sound Control (OSC) is a universal communications protocol optimized for modern networking to enable connections between computers and other multimedia devices. EMOTIV’s BCI-OSC enables EMOTIV Brainwear® and Virtual Brainwear® to interface with a wider variety of OSC compatible hardware and software applications. OSC allows you to send mental commands, facial expressions, or performance metrics to an external, network-connected device.
The following example details the steps to connect EMOTIV’s BCI-OSC with Max MSP, a visual programming language for music and multimedia.
Step 1: Open BCI
Step 2: Select a profile and connect to a headset (virtual or real)
Step 3: Open BCI-OSC tab and set:
- Sending mode: Unicast to Self
- IP: 127.0.0.1
- Port: 8000
- Data Streams: Select the ones you want to use
Step 4: Click Start
Step 5: Open Max MSP, go to File > Package Manager and install CNMAT Externals
Step 6: Go to https://github.com/Emotiv/opensoundcontrol/tree/develop (need permission to access) and check the table with OSC Address Patterns (see image below)
Step 7: Create (replicate) the nodes below and change OSC-route according to whichever OSC Pattern you wish to address (in the example image, Facial expressions/Smile) – check table in the previous step for the addresses.
Step 8: Open Processing and go to Sketch > Import Library… > Add Library , search and install oscP5
Step 9: Open a new File.
Step 10: Import oscP5 to the code and initialize an instance listening to port 12000. Example code (copy and paste in Processing):
import oscP5.*; //OSC receive OscP5 oscP5; // This value is set by the OSC event handler float importedValue = 0; float radius; void setup() { size(1200,1000); // Initialize an instance listening to port 12000 oscP5 = new OscP5(this,8500); } void draw() { background (0); // Scale up imported value radius = importedValue * 1000; // Display circle at location vector stroke(255); strokeWeight(2); fill(255); ellipse(500,500, radius, radius); println(radius); } void oscEvent(OscMessage theOscMessage) { float value = theOscMessage.get(0).floatValue(); importedValue = value; } |
Step 11: Click the Play button and watch the graphics change according to Smile. importedValue is associated with the circle radius.
Step 12: Open any example code in File > Examples…
Step 13: Associate importedValue with any float variable from any Library to play around. Be sure to:
- Import oscP5;
import oscP5.*; //OSC receive OscP5 oscP5; // This value is set by the OSC event handler |
- Initialize importedValue (before void setup);
float importedValue = 0; |
- Initialize oscP5 (place it inside void setup);
// Initialize an instance listening to port 12000 oscP5 = new OscP5(this,8500); |
Associate the event with the variable importedValue (place it after void draw);
void oscEvent(OscMessage theOscMessage) { float value = theOscMessage.get(0).floatValue(); importedValue = value;} |
The new Cortex 2.6.1 also has many other updates and enhancements are waiting for you to explore!