Skip to content

yelabb/PhantomMusic

Repository files navigation

🎵 PhantomMusic

Neural data sonification for the Phantom BCI stack.

Transform brain signals into an interactive musical experience. PhantomMusic streams neural data from PhantomLink and converts neuron firing patterns into real-time synthesized music.

TypeScript React Tone.js Tailwind

image

✨ Features

  • 🎹 Neural Orchestra — 142 neurons mapped to 4 instrument groups (synth, drums, bass, pad)
  • 🎯 Target Chords — MC_Maze targets trigger harmonic chord progressions
  • 📊 Live Visualization — Real-time neural activity display with color-coded neuron groups
  • 🔬 Diagnostic Tools — Mapping inspector and scientific target protocols
  • 🎛️ Audio Controls — Multiple scales (pentatonic, minor, major, blues), volume, mute
  • 🔗 PhantomLink Integration — Direct WebSocket streaming from neural datasets

🚀 Quick Start

# Install dependencies
npm install

# Start dev server
npm run dev

Open http://localhost:5173 and enter a PhantomLink session code.

🎼 How It Works

Neuron Group Channels Instrument Sound
Synth 0-35 PolySynth Melodic leads
Drums 36-70 MembraneSynth + MetalSynth Kick & hi-hat
Bass 71-105 MonoSynth Deep bass lines
Pad 106-141 FMSynth Ambient textures

When the target position changes in the dataset, a corresponding chord plays:

  • Target 0 → C Major
  • Target 1 → D Major
  • Target 2 → E Major

🛠️ Tech Stack

  • Vite + React 19 + TypeScript
  • Tone.js — Web Audio synthesis
  • Zustand — State management
  • Framer Motion — Animations
  • Tailwind CSS v4 — Styling
  • msgpack-lite — Binary WebSocket decoding

📡 PhantomLink Connection

PhantomMusic connects to PhantomLink's binary WebSocket stream:

wss://phantomlink.fly.dev/stream/binary/{sessionCode}

Messages are MessagePack-encoded StreamPacket objects containing:

  • spike_data.spike_counts — 142-channel spike counts
  • kinematics.velocity — Movement velocity
  • intention.target — Predicted target (0, 1, or 2)

🎨 Part of the Phantom Stack

Project Description
PhantomCore C++ real-time neural decoder
PhantomLink Python streaming server
PhantomLoop React visualization dashboard
PhantomX PyTorch neural network training
PhantomSpecs Protocol specifications
PhantomZip Rust neural compression codec
PhantomMusic 🎵 Neural sonification (you are here)

🙏 Acknowledgments

This project was developed with assistance from AI coding assistants and workflows:

  • Claude Opus 4.5 (Anthropic)
  • Claude Sonnet 4.5 (Anthropic)
  • Gemini 3.0 Pro (Google)
  • Grok code fast 1 (xAI)

MIT

About

Real-time spike-level BCI streaming → music

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published