Streaming 2 Channels of EEG through stereo out with OSC -> Pd
Hi all,
I have been working on a small side project with my team using OSC and Puredata and was hoping for some help with it.
The idea is to use OSC to stream 2 channels of EEG to Puredata and then out again via our sound card as an analog (audio) signal.
Obviously a regular sound card is going to automatically filter signals below 30Hz so we opted to get a Komplete Audio 6 mk2 which has DC-coupled outs. To make proper use of these outs we soldered together 2 floating ring to BNC cables (1/4" TRS with the tip and shield connected to the signal and shield of a BNC, respectively). Using a sine wave oscillator in Puredata we can confirm that very low frequency signals (at least down to 1Hz) come through without any attenuation.
Streaming from the GUI is straightforward enough. I am able to receive the signal in Puredata and print to console. However, when sending these signals back out via the DAC, the output is choppy and inconsistent. I was able to get a slightly better looking signal by attenuating the values from the OSC messages before sending to the DAC, but it's still far from looking like the original EEG data we see in the GUI.
My Pd sketch is as follows (I'm using the mrpeach library for OSC)

I have fiddled around with audio settings in Puredata but nothing seems to change the choppy output. I'm wondering if it's just the nature of the network protocol? Should I expect to be able to do this or am I overestimating the consistency of data transfer in this type of stream? I don't have a good sense as to why it's not a continuous at the audio out, so if anyone has suggestions or input as to why this happens I'm happy to hear them!
Comments
Brian, hi.
Have you tried the Google Search button (upper right) on other OSC related posts? I came across this thread regarding Max/MSP, where Richard @retiutut was commenting. Richard is our OpenBCI GUI expert.
http://openbci.com/forum/index.php?p=/discussion/2234/max-msp-connection
Hoping he will comment on your Puredata patch. I know Max and Pd share roots, so should be similar as far as getting EEG data.
Regards, William
To anyone else viewing this thread, this is similar to Alvin Lucier's "Music for Solo Performer" http://daily.redbullmusicacademy.com/2017/05/alvin-lucier-music-for-solo-performer.
@BCoughlin You are well on your way to creating something neat! I understand that you want raw EEG data turned almost directly into sound waves. There may be a cutoff for < 30Hz somewhere, so thanks for testing using a sine wave.
I do have experience with MaxMSP and PureData.
Hi @wjcroft. Thanks for the link, I had searched and another user with a similar goal - trying to use the audio out from puredata for biofeedback (http://openbci.com/forum/index.php?p=/discussion/comment/7971#Comment_7971) though it seems like it never came to fruition for them. I did find the links there regarding DC-coupled outs helpful, so thanks for providing those!
@retiutut Very cool link there! You're correct that I'd like to have basically raw EEG as an audio signal.
Here is a link to my .pd file for the code:
https://github.com/BeeCoughs/OpenBCIAudio
I added a plot functionality, but it's not very elegant. That said, the output from it has me back to thinking about sample rates as a possible culprit for the choppiness. When my plot loops through 5 seconds at 250Hz, several data points are skipped over in the array (they are left at initialized values) which I would expect to not happen if the OSC data is indeed being transferred at that rate (I'm assuming it's the same as the Cyton sampling rate, though I couldn't confirm that). Perhaps the solution is to have some sort of buffer that updates every time a sample comes in and flushes once a second, or after collecting a certain number of samples? My thinking is that, while having minimal delay would be ideal, at least a consistent one could be accounted for.