Ben Deverett, MUMT306 Final Project


--Summary--
The goal of this project is to create simple Python-based HCI (specifically BCI) musical instrument by integrating the input from an external EEG sensor with a MIDI-based music-making algorithm. The EEG sensor, a single electrode placed on the forehead, records fluctuations of electric fields through the skull caused by large-scale changes in brain activity. This data is transmitted to the computer wirelessly as a time series of recordings, and this signal is then decomposed into frequency bands. An algorithm will be employed to determine which, if any, activities will produce consistent and unique signals (for example: blinking/thinking/focussing). Once calibrated, the user will play the device by reproducing these activities, giving rise to signals which will trigger MIDI notes played through the virtual synthesizer.
--Hardware--
--Software--
--Algorithms--
(This section lists some of the most important methods of the project.)

--Overview--
The project is defined as a class called Project in the module project.py, so that it can be imported and used as an object in a python script. A project object is initialized with one parameter called play_mode. Available play_mode values are 0 and 1, where 0 corresponds to "freestyle mode" and 1 to "record mode". When instantiated, the Project object creates a Client object through which it will interact with the sensor. The initialization of this Client object is automatic, establishing a connection to the socket and configuring the device for JSON-formatted raw-output. The Client object also creates a Data object, used to store and analyze all sensor data during the session. Next, the Project object prompts the user to enter 10 seconds of training, during which the user is meant to sit still with minimal blinking. The data collected is stored in the client's Data object, and baseline data parameters are calculated and stored. After creating its client, the Project object creates a midiout object to be used for all outbound MIDI messages. At this point, the Project object remains dormant until the go() method is called, at which point the musical loop begins. Based on preset parameter values specified in the project.py module, a musical loop begins to play, trackable by a constant metronome. The tempo of the loop can be changed by modifying the parameters in the beginning lines of project.py. The loop consists of one bar, which for simplicity, corresponds to a single whole note at the specified tempo. In freestyle mode, the loop proceeds to indefinitely check sensor input while maintaining the musical loop. If a message is detected, as determined by the gotSignal() method in the Data object, a MIDI message is sent through the midiout object. The files are written such that they support the detection and interpretation of multiple sensor-message types, allowing for the possibility of sending different MIDI notes based on the type of message. Record mode consists of a more complex loop which alternates between "record" bars, during which the user can send new messages, and "break" bars, during which the user can listen but not send messages. The record bars are indicated by a constant MIDI tone playing in the background. The duration of a 'record bar' is similar to freestyle mode in that notes will be played when messages are received, however, every note is then adjusted for timing and stored. [The object's resolution parameter determines the frequency with which the notes of the loop can be analyzed for recording and playback. For example, a resolution of 16 allows 16 separately timed notes (each being a 16th note) to be played over one bar. When notes are adjusted, they are matched to the nearest note of the specified resolution.] The 'record bars' cycle through a series of MIDI drum notes (which can be easily added to or modified) in order to allow the creation of multi-drum beats. Every subsequent bar plays all timing-fixed notes at their proper time. The duration of break bars allows the user to hear what they have recorded without the ability to modify it. The loop continues until stopped manually.
--Progress--
--Source--
The source code for this project can be found here.
The a.py script runs an instance of the project.