Example connection with MaxMSP
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.
- 1.Connect a simulated device or an OSC compatible EMOTIV Brainwear®
- 2.
- 3.Select Sending mode: Unicast to Self
- 4.Set the IP: 127.0.0.1
- 5.Set the Port: 8000
- 6.Choose the Data stream you want to connect: Facial expressions, Mental Commands, or Performance Metrics
- 7.Click Start
- 8.Open Max MSP, go to File > Package Manager and install CNMAT Externals
- 9.Go to https://github.com/Emotiv/opensoundcontrol/tree/master and check the table with OSC Address Patterns
- 10.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.
- 11.Open Processing and go to Sketch > Import Library… > Add Library , search and install oscP5
- 12.Open a new File.
- 13.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;
} |
Last modified 1yr ago