Skip to content

Feat/neurostate games - #2

Open
MichalSzandar wants to merge 14 commits into
NoMoreCookies:mainfrom
KN-Neuron:feat/neurostate-games
Open

MichalSzandar wants to merge 14 commits into
NoMoreCookies:mainfrom
KN-Neuron:feat/neurostate-games

Conversation

@MichalSzandar

Copy link
Copy Markdown

Summary

KNeuron can now run the native Neurosniper and Neurorun builds, controlled by attention and relaxation from neurostate, with a BrainAccess MIDI, on Linux. It also gains a Signal Check module for fitting the cap.

BrainAccess MAXI / MIDI → brainaccess-bridge ──→ raw EEG → Cortex 3D, TaaLON Miner
                                 └─ LSL "KNeuron <device>" → neurostate-bridge
                                      ├─ 127.0.0.1:13855 → Neurosniper, Neurorun
                                      ├─ ThinkGear 13854, WebSocket 13856, LSL
                                      └─ stdout → game screens, Neuorrun, Signal Check

Changes

BrainAccess MIDI

  • New device card. Connects to any BA MIDI … headset.
  • Uses BrainAccess Board's MIDI pin order (P8, O2, P4, … F7), with bias feedback from pin 0.
  • Model specifics live in brainAccessProfiles.ts. MAXI behaviour is unchanged.
  • While streaming, brainaccess-bridge republishes the EEG on LSL. Timestamps come from the device's sample counter. If LSL fails, the raw EEG for Cortex and Miner keeps flowing.

neurostate sidecar (neurostate-sidecar/)

  • Wraps the neurostate library. Installed from the commit pinned in neurostate.txt, or from NEUROSTATE_SRC.
  • Bundles cap profiles: brainaccess-midi uses the MIDI montage and allows 10× mains hum on dry electrodes.
  • NeuroStateService runs it while the cap is connected, so the one-minute resting baseline carries over between games.
  • BrainMetricsService falls back to it for raw EEG caps, so Neuorrun (WebGL) also works with BrainAccess.

Native games (src-tauri/src/games.rs, releases.rs, src/modules/externalGame/)

  • PLAY asks GitHub for the latest release and downloads <Name>-linux-x86_64-<tag>.tar.gz or <Name>-windows-x64-<tag>.zip.
  • It verifies GitHub's SHA-256 digest, unpacks into <app data>/games/<id>/<tag>/ (keeping only the newest), and launches the game.
  • Offline, PLAY falls back to the installed version. LOCAL BUILD... plays an unreleased build.
  • Safety: the shell only downloads from the games' own release URLs, and only launches known games from an executable named like the game. Neurorun's Windows Neuorrun.exe is accepted.
  • QUIT GAME sends SIGTERM and kills the game after 5 s. Games close with KNeuron.

Signal Check (src/modules/signalCheck/)

  • The sidecar's check mode runs neurostate's own filter and assess_channels with the cap's profile.
  • The module shows live traces coloured by status, regions, problems, gaps and the O1/Oz/O2 spectrum with alpha shaded.

Linux

  • vite.config.ts no longer watches the sidecars' .venv/build/dist folders, which exhausted inotify watches (ENOSPC).
  • setup-and-run.sh, setup-and-run.ps1 and CI build or test the new sidecar. Python 3.12+ is required.

Testing

  • Frontend: 141 tests, lint, prettier and npm run build.
  • Sidecars: brainaccess (20) and neurostate (15) tests. The neurostate tests run real LSL mock streams.
  • Rust: 15 tests, plus an ignored one that downloads and installs the real Neurorun release (cargo test --lib -- --ignored real_release).
  • Frozen binaries on Ubuntu 24.04:
    • Mock MIDI stream → neurostate: full quality, with values on 13855 and 13854.
    • BrainAccess LSL outlet → neurostate.
    • Signal check: 16 channels, alpha peak at about 9–10 Hz.
  • KNeuron on Linux (tauri:dev): Dashboard, Device page, game screen, file dialog, launch, leave and re-enter, QUIT GAME (checked with a stand-in executable).

Not tested: connecting a real MIDI (the BLE scan found no headset at the time), the Windows bootstrap and build scripts, and a MAXI regression on hardware.

Notes for reviewers

  • MAXI pin order: Board's MAXI template uses a different order (pin 0 = P8) from the one hardcoded here (AF3 first). Worth confirming on the cap; left unchanged.
  • Two Neurorun cards: the Dashboard now shows both "Neuorrun" (WebGL, embedded) and "Neurorun" (native). We could remove the WebGL one later.
  • Generated files: src-tauri/gen/schemas/* are regenerated by Tauri, which causes a large diff. They're now excluded from prettier.
  • npm run typecheck checks nothing, because the root tsconfig.json has files: []. npm run build does the real type check.
  • neurostate API changes: bump the commit in neurostate-sidecar/neurostate.txt and rebuild the sidecar.

Try it

./setup-and-run.sh --skip-system

Then connect your BrainAccess cap on the Device page and open Signal Check, Neurosniper or Neurorun.

pawel120 and others added 14 commits October 3, 2026 13:19
- Support the BrainAccess MIDI: model profiles in the BrainAccess adapter
  (MIDI pin order and bias from Board's template); the sidecar reports the
  model and republishes EEG on LSL while streaming.
- Add the neurostate sidecar: runs the neurostate library on the cap's LSL
  stream and publishes attention/relaxation on 13854-13856 for the games,
  and to KNeuron over stdout. BrainMetricsService falls back to it for raw
  EEG caps, so Neuorrun (WebGL) works with BrainAccess too.
- Add Neurosniper and Neurorun modules: PLAY installs the latest GitHub
  release (SHA-256 checked) and launches it; LOCAL BUILD... overrides.
  The shell only launches the known games and only downloads their own
  releases.
- Add Signal Check: neurostate's `check` inside KNeuron, with live traces,
  per-channel status (flat/noisy/mains), regions, gaps and alpha spectrum.
- Fix Linux dev: Vite watched the sidecars' .venv folders and ran out of
  inotify watches; build the new sidecar in both bootstraps and CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants