Bio:gram is a browser-based AI DJ/VJ system with:
- Dual-deck realtime music generation via Google Lyria (
lyria-realtime-exp) - AI-generated integrated mix plan (JSON) via Gemini 3 Pro (
gemini-3-pro-preview) for mix planning only - Lightweight AI tasks (grid/analysis/prompt helpers) via Gemini Flash Lite (
gemini-flash-lite-latest) - AudioWorklet-based DSP and deck mixing
- Live visuals (Three.js-based) that react to mixer/FX/analysis events
- Local loop library (IndexedDB) with save/load/import/export/recommend features
- Two decks (
A/B) with independent play/stop, sync toggle, BPM adjust, TAP BPM, prompt input, GEN trigger - Deck waveform/visual area (
hydra-visualizer) and deck-level generated prompt display - Deck sync logic with BPM ratio + phase alignment in
AudioEngine
Relevant code:
src/ui/modules/deck-controller.tssrc/audio/engine.ts
- App starts with an initialization overlay (
INITIALIZE SYSTEM) - On init, AudioWorklet is loaded, Lyria sessions connect for both decks, and generation begins
- Deck GEN updates or resets prompt context (hard reset when deck is stopped)
- Prompt text is built from UI state (ambient/minimal/dub/impact/color, texture/pulse, key/scale, deck personality, slam state)
Relevant code:
src/main.tssrc/ai/prompt-generator.tssrc/ai/music-client.ts
- Super Controls can request mix generation for
A->BorB->A - Mix request includes direction, duration (16/32/64/128), mood, preferred visual mode
- Gemini 3 Pro returns an integrated mix plan, then
audio_planis executed asAutomationScore AutomationEngineexecutes score curves over bars with interpolation and safety guards- UI states:
IDLE -> GENERATING -> READY -> MIXING
Relevant code:
src/ui/modules/super-controls.tssrc/ai/mix-generator.tssrc/ai/automation-engine.ts
- Audio path is handled by AudioWorklet processor
- Mixer controls include crossfader and deck EQ/kill/trim/drive mappings
- FX rack exposes multiple modules including filter, tape echo, bloom reverb, spectral gate, cloud grain, decimator, dynamics
- SLAM macro applies energy-riser style macro control (filter/res/drive/noise)
Relevant code:
src/audio/worklet/processor.tssrc/audio/worklet/dsp/*src/ui/modules/dj-mixer.tssrc/ui/modules/fx-rack.tssrc/main.ts
- Main controller view includes background
three-viz - Visual controls support:
- mode switching (
organic,wireframe,monochrome,rings,waves,suibokuga,grid,ai_grid) - deck texture upload (image/video), webcam toggle
- blur FX and rendering on/off
- projector window via
/?mode=viz - zen mode overlay controller
- mode switching (
- AI grid parameter generation is available via Gemini
- Visual score sync now uses audio frame timing (
startFrame/endFrame) produced byMusicClientto reduce drift
Relevant code:
src/ui/visuals/ThreeViz.tssrc/ui/visuals/VisualControls.tssrc/ai/grid-generator.ts
- Save current deck audio as loop (8/16/32/64/128 bars)
- Audio validity check before saving
- IndexedDB storage with tags, vector metadata, BPM, prompt
- Import audio files, export WAV, delete loops
- Recommend loops from current deck vector similarity
- Sidebar open/close uses explicit visibility control (
setLibraryPanelVisible) for stable toggle behavior
Relevant code:
src/ui/modules/loop-library-panel.tssrc/audio/db/library-store.tssrc/audio/utils/audio-analysis.tssrc/ui/bootstrap/library-sidebar.ts
- Bottom fixed mobile tab bar for quick view switching (
DECK / FX / VISUAL / AI MIX) - Mobile deck mini controls optimized for touch targets (larger PLAY/GEN/BPM controls)
- GEN button includes short pulse feedback animation
- UI/Main Thread:
- Lit components + orchestration in
main.ts - AI API calls (mix generation, visual analysis/grid generation)
- Bootstrap modules for event wiring and lifecycle cleanup:
src/ui/bootstrap/deck-transport-events.tssrc/ui/bootstrap/visual-sync-events.tssrc/ui/bootstrap/library-sidebar.tssrc/ui/bootstrap/zen-overlay.ts
- Lit components + orchestration in
- Audio Thread:
- AudioWorklet processor reads/writes from SharedArrayBuffer
- DSP modules process deck/master signal
- Data:
- IndexedDB for loop/chunk archive (
promptdj-ghost-memory)
- IndexedDB for loop/chunk archive (
- Node.js 18+
- Google API key with access to Gemini and Lyria endpoints used in the code
npm installCreate .env in project root:
GEMINI_API_KEY=your_api_key_hereNotes:
GEMINI_API_KEYis used only on the local backend middleware (/api/*) and is not exposed to browser code.- Realtime Lyria deck generation still uses the local API key entered in the app's API settings dialog (client-side), until a WS relay path is introduced.
npm run devOpen: http://localhost:3000
- Click
INITIALIZE SYSTEM. - Use deck controls to play decks and adjust BPM/prompt.
- Press
GENon a deck to apply/update AI prompt. - Open
SUPERview and requestA->BorB->Amix. - When score is ready, press
START MIX. - Optionally switch visual modes or open projector mode.
- Save loops to library and reload/import/export as needed.
Bio:gram now exposes AIMIX controls to in-browser agents via WebMCP (Imperative API).
aimix_generate: request mix generation (single/free mode).aimix_start: start generated mix (READYrequired).aimix_cancel: cancel generated mix before start (READYrequired).aimix_abort: stop running mix (MIXING/WAIT_NEXT/POST_REGENrequired).aimix_get_state: read current AIMIX/deck state snapshot.
- Use Chrome
146.0.7672.0or newer. - Open
chrome://flags/#enable-webmcp-testingand set WebMCP for testing toEnabled. - Relaunch Chrome.
- Start Bio:gram (
npm run dev) and open the app tab. - (Recommended) Install and open Model Context Tool Inspector extension to:
- confirm registered tools
- run tools manually
- test natural-language invocation via Gemini in the extension
- Ask user to click
INITIALIZE SYSTEMfirst. - Call
aimix_generatewith desired parameters. - Poll
aimix_get_stateuntilmixState === "READY". - Call
aimix_start. - During playback, use
aimix_get_state(andaimix_abortif needed).
- This implementation is WebMCP (browser-native, tab context required), not a standalone MCP server endpoint.
- If you need remote/server-side MCP clients, add a separate MCP server layer that calls app/backend APIs.
There is no npm test script yet.
Current verification helpers:
scripts/eval-beat-detector.tsscripts/eval-beat-detector.jspy_bridge/analyze.pypy_bridge/test_analyze.py
- This app relies on
SharedArrayBuffer; COOP/COEP headers are configured for Vite dev server invite.config.ts. - Docker/Nginx config currently serves SPA assets but does not add COOP/COEP headers by default.
- Product behavior depends on external model availability, quota, and API latency.
src/
ai/ Gemini/Lyria clients, automation score generation
audio/ AudioEngine, analysis, worklet DSP, IndexedDB store
ui/ Lit components, deck/mixer/super/visual controls
midi/ MIDI manager
types/ shared and domain types
MIT



