From a signal to your first action.
This reference describes the browser demo and the source modules in this repository. The hosted SDK, localhost:8080 bridge, and Calm/Focus events shown in concept examples are not released products.
Try it in seconds.
- Open the playground. Recorded EEG playback starts automatically. No account or headset required.
- Watch the EEG waveform trigger the newt.
- Pause stops the game and waveform. Resume continues the demo.
Run the source locally
git clone https://github.com/sarthakjena05/nervenewt.git
cd nervenewt
npm install
npm run devWhat works today.
| Input | Status |
|---|---|
| Recorded EEG playback | Available; real AF7 recording at 160 Hz, no hardware. |
| Muse 2 | Web Bluetooth driver implemented; physical-headband verification pending. |
| OpenBCI, EMG, ECG/PPG | Planned; no production adapters or release dates. |
To try Muse 2, use Chrome or Edge on HTTPS or localhost. Turn on the headset, click + Connect device, and choose it in the browser picker. If another app is connected, disconnect it first. Cancelling pairing or losing the stream returns to recorded playback.
Events you can handle.
| Live event | Meaning in this prototype |
|---|---|
blink | Forehead voltage excursion above 120 µV; 350 ms debounce. |
eyes.closed | Relative alpha exceeds 0.45 for over 400 ms. |
eyes.open | Alpha falls below the closed-eye threshold. |
Playback emits signal.peak on voltage crossings above 60 µV with a 700 ms debounce. These are illustrative triggers, not validated measurements of attention, emotion, or medical state.
A working source-level example.
Use this inside the repository. Call connect from a click handler so the browser can open its Bluetooth picker.
import { MuseProvider } from "./src/providers/MuseProvider.js";
const connectButton = document.querySelector("#connect"); // your button
const stream = new MuseProvider();
const unsubscribe = stream.subscribe(event => {
if (event.type === "event" && event.name === "blink") {
document.body.classList.toggle("blink-active");
}
});
connectButton.addEventListener("click", async () => {
try { await stream.connect(); }
catch (error) { console.error(error.message); }
});
// When leaving the page or disposing the integration:
// unsubscribe();
// stream.disconnect();connect(): Promise<void>- Requests a device, subscribes to four EEG channels, and starts streaming. Rejects on cancellation or connection failure.
subscribe(listener): () => void- Receives status, frame, and event messages. Returns an unsubscribe function.
setPaused(boolean)- Pauses emitted frames and detections while keeping the Bluetooth connection.
disconnect()- Releases listeners, animation callbacks, buffers, and the GATT connection.
Frame payload
{
type: "frame",
channels: [TP9, AF7, AF8, TP10], // µV arrays, up to 256 each
replace: true,
alpha: 0.52, // relative power, not attention confidence
timestamp: 3.2, // seconds since connection
drop: 0 // missing/malformed packets across channels
}Small, local, and explicit.
EEG samples stay in browser memory. Four channels stream at 256 Hz; spectral analysis runs at 10 Hz, waveform rendering at up to 25 Hz, and gameplay uses its own animation loop. End-to-end latency has not been benchmarked on physical hardware.
Different hardware needs different adapters, calibration, and event validation. The shared provider interface is the current abstraction; broad device coverage is a roadmap, not a claim of compatibility. Hardware protocols can change.
Early-access forms send contact information only when an intake or email service is configured. They do not submit EEG data.