OpenInterface final “code”

Here is the OpenInterface “code” used for the demonstration (click to zoom) :

As you can see, we have not needed a lot of blocks to interface ALL our sensors AND send the data !
When a block is drawn (less than 30 minutes for the EPOC block) it takes only a few minutes to connect it with others and make an application. So, with OpenInterface it’s possible to develop a prototype for any type of projet in one day.

Explanation of the code 

First of all, we can see the sensors’ blocks:

  • EPOC – used to get the data from the emotiv headset
  • RXTXComm – used to get the data from the heartbeat counter

Heartbeat counter

The RXTXComm component is a generic serial component, it can be used for any kind of serial communication. The 2 blocks placed before it (Metronome and Sequence) are used to make a periodic request to the serial port. We send the command (“G1\x0D\x0A”) to the heartbeat counter and, after, we read the data from the serial port until the character “\x0D” (carriage return) is detected (end character of the heartbeat counter).

We remove the “space” character between all data (String tokenizer) to keep only the usefull ones and we merge these values into an array to cast the strings into double (ParameterListsToArray).

The final step, for the heartbeat counter, is to split the double array (ParameterListFromArray) to keep only the heartbeat value and send it to the interface via OSC messages to move the center of the speaker (like a heart beating).

EMOTIV EPOC

We used “only” 5 different information from the headset in our application.

  • “Blink”
  • “Smile”
  • “Clench”
  • Eyebrows movements
  • Head movements

“Blink”, “Eyebrows” and “Smile” are sent to KYMA via OSC messages to modify the sounds parameters, “Clench” and “head movements” are sent to the interface to modify the visual part (we rotate the speaker border to change the picture used with the head movements and we show all the possible actions when the user is clenching).

The values from the EPOC are binary values (the user is smiling or not). And, use a binary value in this application would not give a good result. It’s why we have used a RANDOM component. This component generates a pseudo-random value each time we activate it.

The blocks “OnInputChanged” and “MulIfThenElse” are used to send a signal only when an event occurs (on the “low-to-high” changement) and the block “Rescale” is used to cast the BOOL values into double (to be accepted by the processing’ OSC library).

Components C++ code

For this project we only had to write the driver for the EPOC and the RANDOM components (all the other functions were already in OpenInterface therefore we didn’t need to worry about it).

For those who want, here are the C++ code used for this 2 components:

RANDOM

 Random_Facet.h

Random_Facet.cpp

EPOC

Epoc_Facet.h

Epoc_Facet.cpp


Comments are closed.