Real-time brainwave visualization using Enophone EEG headphones with BrainFlow SDK.
- Python 3.8+
- Enophone headphones (optional - can run in simulation mode)
- Bluetooth (for real device)
- Create a virtual environment:
python -m venv venv- Activate the virtual environment:
# Linux/macOS
source venv/bin/activate
# Windows
venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Start the WebSocket server (simulation mode for testing):
python enophone_websocket_server.py --simulate- Open
enophone-art.htmlin a browser:- Drag the file into a browser, OR
- Run:
python -m http.server 8080then visithttp://localhost:8080/enophone-art.html
-
Find your Enophone MAC address:
- Linux:
bluetoothctl devices - Windows: Device Manager → Bluetooth Address
- Linux:
-
Start the server with your MAC:
python enophone_websocket_server.py --mac XX:XX:XX:XX:XX:XX- Open
enophone-art.htmlin a browser
python enophone_http_server.py --mac XX:XX:XX:XX:XX:XX
# Metrics available at http://localhost:8080/metricsEnophone has 4 EEG sensors positioned at standard 10-20 system locations:
| Channel | Position | Description |
|---|---|---|
| A1 | Left ear (mastoid) | Reference electrode |
| C3 | Left motor cortex | Left hemisphere brain activity |
| C4 | Right motor cortex | Right hemisphere brain activity |
| A2 | Right ear (mastoid) | Reference electrode |
The sensors capture brainwave data from the frontal parietal lobe (involved in sustained attention) and can detect all 5 brainwave types:
- Gamma (40 Hz): Peak focus, high alertness
- Beta (13 Hz): Active thinking, concentration
- Alpha (10 Hz): Relaxed flow, creative states
- Theta (7.83 Hz): Deep relaxation, meditation
- Delta (1-4 Hz): Deep sleep
The raw EEG voltage data from the 4 sensors is processed to extract brainwave band powers:
Raw EEG Signal → FFT (Fast Fourier Transform) → Power Spectral Density (PSD) → Band Powers
- Raw EEG: Each channel records voltage fluctuations in microvolts (µV)
- FFT/PSD: Converts time-domain signal to frequency-domain, showing power at each frequency
- Band Power: Integrates power within specific frequency ranges for each band
| Band | Frequency Range | How It's Calculated |
|---|---|---|
| Delta | 0.5-4 Hz | Sum of PSD from 0.5-4 Hz |
| Theta | 4-8 Hz | Sum of PSD from 4-8 Hz |
| Alpha | 8-13 Hz | Sum of PSD from 8-13 Hz |
| Beta | 13-30 Hz | Sum of PSD from 13-30 Hz |
| Gamma | 30-50 Hz | Sum of PSD from 30-50 Hz |
The focus score is derived from the Beta/Alpha ratio:
Focus Score = (Beta Power / Alpha Power) × 100
Higher Beta (active thinking) relative to Alpha (relaxation) indicates better focus. Values are clamped between 0-100.
| Script | Description |
|---|---|
enophone_websocket_server.py |
WebSocket server for real-time visualization |
enophone_http_server.py |
HTTP API for Grafana/polling |
enophone_monitor.py |
CLI brainwave monitor |
enophone_monitor_gui.py |
GUI visualization with matplotlib |
enophone_ios_client.py |
iOS proxy - connects to remote server and re-broadcasts locally |
enophone-art.html |
WebGL visual art (browser-based) |
# With simulated data (no hardware needed)
python enophone_websocket_server.py --simulate
# With real device (MAC required on Linux)
python enophone_websocket_server.py --mac XX:XX:XX:XX:XX:XX --port 8765python enophone_monitor.py --mac XX:XX:XX:XX:XX:XXpython enophone_monitor_gui.py --mac XX:XX:XX:XX:XX:XX --guiSince BrainFlow requires direct Bluetooth access which doesn't work on iOS/macOS, use this architecture:
-
Linux machine (has Bluetooth access):
python enophone_websocket_server.py --mac XX:XX:XX:XX:XX:XX
-
iOS/macOS device (runs the proxy):
# Connect to remote Linux server and expose locally python enophone_ios_client.py --host <linux-ip> --remote-port 8765 --local-port 8765
-
Local apps connect to:
ws://localhost:8765
The proxy receives data from the Linux server and re-broadcasts it locally, allowing any app on iOS/macOS to connect as if the server were local.
The WebGL art (enophone-art.html) displays:
- Flow fields: Color-coded by channel (A1, C3, C4, A2)
- Calm indicator: Central ripple effect when all channels near ideal range
- High spike fireworks: When values exceed ±1000
- Low zone fireworks: When values are between -25 and 25
- Intensity damping: Values >1000 are reduced by 50% to prevent saturation
- Connection refused: Ensure WebSocket server is running (
python enophone_websocket_server.py --simulate) - No data from device: Check Bluetooth pairing and MAC address
- Linux requires MAC: Unlike Windows/macOS, Linux requires explicit MAC address
This software is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
This project is for educational and personal use only. It is not a medical device and should not be used for medical diagnosis or treatment. The brainwave data collected by this software may not be accurate or reliable enough for clinical purposes.






