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.
Once you subscribe to the OSC module, the tab is enabled in BCI. The following example demonstrates a connection of EMOTIV BCI with MaxMSP, which is a visual programming language for music and multimedia.
Connect a simulated device (create one on EMOTIV Launcher if you don't have. See Creating a virtual brainwear) or an OSC compatible EMOTIV Brainwear®
Choose a training profile to connect to the external device.
Select Sending mode: Unicast to Self
Set the IP: 127.0.0.1
Set the Port: 8000
Choose the Data stream you want to connect: Facial expressions, Mental Commands, or Performance Metrics
Click Start
Open Max MSP, go to File > Package Manager and install CNMAT Externals
Go to https://github.com/Emotiv/opensoundcontrol/tree/master and check the table with OSC Address Patterns
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.
Open Processing and go to Sketch > Import Library… > Add Library , search and install oscP5
Open a new File.
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;
}
14. Click the Play button and watch the graphics change according to Smile. importedValue is associated with the circle radius.
15. Open any example code in File > Examples.. 16. 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;
}