An autonomous, local-AI symphonic song architect built on Rust and Strudel.
MotifAI bridges local large language models (LLMs), including Qwen2.5-Coder, Devstral, Mistral, and DeepSeek, with the Strudel.cc live-coding music environment.
As of v6.8.0, MotifAI combines:
- A work-mode-aware Composition Orchestrator.
- The 65-architecture Master Composition & Performance Palette.
- Live NDJSON token streaming with VRAM-aware inference profiles.
- A two-stage verification loop: Conservative Lexical Preflight followed by Embedded Strudel REPL Runtime Evaluation.
Describe your musical vision and style DNA, and MotifAI autonomously structures, codes, validates, and arranges an executable Strudel JavaScript composition in real time. You control the creative steering: use Smart Auto, switch to Free-Form for zero blueprint injection, or opt in to Golden Scorebook tracks and Empirical Memory Advisory whenever you choose[cite: 3, 6, 7, 10].
Interface preview: View the MotifAI interface
Browse and select from 65 composition architectures spanning small, medium, extended, and concert scales, 31 instrument role palettes, 13 production palettes, and 11 visual telemetry families.
Choose one of three modes:
- Smart Auto: Matches one flexible architecture seed to each request.
- Free-Form (OFF): Uses zero blueprint or palette injection.
- Pinned Blueprint: Locks a specific architecture through
Ctrl+Por by writingblueprint:in your prompt.
MotifAI automatically classifies each request into one of four work modes: New Composition, Targeted Edit, Composition Evolution, or Technical Repair. Narrow edit requests preserve unrelated working stems, while evolution passes inspect existing stem roles and develop the arrangement without freezing section maps.
MotifAI automatically prioritizes fast, GPU-resident 14B coder models, such as qwen2.5-coder:14b, for interactive responsiveness on GPUs with 8 GB of VRAM. Larger 24B–32B models remain available through Ctrl+M.
Tokens stream live over NDJSON with real-time tokens-per-second telemetry and task-aware context/output caps. Available profiles are interactive-fast, interactive-extended, deep-balanced, and deep-extended.
Every candidate score must first pass Conservative Lexical Preflight, which checks balanced delimiters, mini-notation brackets, tempo presence, wired sliders, and active musical stems. It also repairs standalone @number filter strings, such as .lpf("@200") into .lpf(200), without rewriting your melodies.
Candidates that pass preflight are then evaluated inside the pinned @strudel/repl@1.3.0 browser runtime. If preflight or runtime evaluation fails, MotifAI feeds the exact error and failed candidate code into a low-temperature repair pass at 0.25.
Manage your local knowledge/golden_tracks folder through an interactive overlay. Pin up to two reference tracks or use weighted stochastic rotation. Golden Tracks are OFF by default and are never injected unless you explicitly enable them.
Frequency-weighted, phrase-aware retrieval dynamically pulls up to three curated Strudel syntax and DSP cards from knowledge/strudel_production_library.json, based on your vision, style DNA, and any active compiler/runtime errors.
MotifAI records AST and runtime outcomes alongside explicit Like (Ctrl+Y) and Revise (Ctrl+N) signals. Prompt injection stays OFF by default until you turn Memory Advisory on with Ctrl+A.
Step backward with Ctrl+Z and forward with Ctrl+U through generated and evolved scores. Cancel an in-flight generation safely with Esc. Use Ctrl+S to save both masterpiece.strudel.js and timestamped backups in exports/.
MotifAI serves the local Visual Studio at 127.0.0.1:7777 using Base64-only editor hydration to prevent HTML comment injection, token-verified runtime reports, and client heartbeat tracking.
Pasted HTTP(S) reference URLs are streamed with a 256 KB cap, stripped of script/style tags, blocked from private/loopback networks, and isolated as untrusted reference data.
You need Rust and Ollama installed to run MotifAI.
Windows: Download and install Ollama from ollama.com/download/windows.
Linux: Run the official install script in your terminal:
curl -fsSL https://ollama.com/install.sh | sh
MotifAI v6.8.0 automatically sizes context windows by model class:
- 14B models: 32,768 tokens.
- 24B–32B models: 16,384–24,576 tokens.
These settings are intended to help GPUs with 8 GB of VRAM avoid stalling or spilling excessive KV cache into system RAM.
To keep models warm in memory between runs on Windows:
- Press
Win + R, typesysdm.cpl, press Enter, and select Environment Variables. - Add a User variable named
OLLAMA_KEEP_ALIVEwith the value-1or20m. - Fully quit Ollama from the Windows system tray, then relaunch it.
Open a terminal and pull a coding model. qwen2.5-coder:14b is the recommended default for fast, GPU-resident interactive composition on GPUs with 8 GB or more of VRAM. You can also install qwen2.5-coder:32b for offline or deep-composition passes.
- Recommended interactive default:
ollama pull qwen2.5-coder:14b - Optional heavy model:
ollama pull qwen2.5-coder:32b
- Install Rust from rustup.rs if you have not already.
- Clone the repository:
git clone https://github.com/ShamelesAbyss/MotifAI.git - Enter the project directory:
cd MotifAI - Run the verification test suite:
cargo test - Launch MotifAI:
cargo run --release
MotifAI works out of the box with zero configuration, but the following environment variables are available for custom setups:
STRUDEL_MODEL: Overrides the initial Ollama model selected at startup. Default:qwen2.5-coder:14b.MOTIFAI_COMPOSITION_BLUEPRINT: Sets the initial Master Palette mode toauto(default),off(Free-Form), or a specific blueprint ID.MOTIFAI_NUM_CTX: Overrides the automatic context window size. Valid range:4096to131072.MOTIFAI_NUM_PREDICT: Overrides the maximum generated token cap per pass. Use-1for unlimited output or a value from512to32768.MOTIFAI_STRUDEL_KNOWLEDGE: Points to a custom production-knowledge JSON file. Default:knowledge/strudel_production_library.json.MOTIFAI_COMPOSITION_BLUEPRINTS: Points to a custom blueprint-archive JSON file. Default:knowledge/composition_blueprints.json.
When MotifAI launches, it presents a three-pane Terminal User Interface (TUI). Press Tab to cycle focus between panes.
Describe your desired composition, movements, energy contour, melodies, bridges, solos, live sliders, or targeted edits. You can also include blueprint: to request a specific architecture inline.
Specify genre, synthesis techniques, and rhythmic feel, or paste any public web/YouTube URL to scrape metadata context into the prompt.
View and scroll through the generated Strudel JavaScript score, nudge the tempo in real time, or step through your Undo/Redo generation history.
Ctrl+GorF5· Compose: Builds a brand-new composition from the current Musical Vision and Style DNA.Ctrl+E· Evolve: Feeds the active score back into the orchestrator to develop sections, transform motifs, or apply targeted edits.Ctrl+Z· Undo Score: Returns to the previous score snapshot in the session history and syncs it to the Studio.Ctrl+U· Redo Score: Moves forward to the next score snapshot in the session history and syncs it to the Studio.Esc· Cancel / Close / Exit: Closes an open modal overlay, aborts an in-flight generation without quitting, or exits MotifAI when idle.
Ctrl+P· Master Palette Overlay: Opens the Master Composition & Performance Palette browser. Use Up/Down to browse, Enter/Space to apply, A for Smart Auto, O for Free-Form (OFF), and R to rescan.Ctrl+T· Toggle Golden Tracks: Turns Golden Scorebook reference injection ON or OFF.Ctrl+B· Golden Scorebook Overlay: Opens the interactive Golden Scorebook forknowledge/golden_tracks. Use Up/Down to navigate, Space/Enter to pin or unpin up to two tracks, T to toggle Golden mode, C to clear pins, and R to rescan.Ctrl+A· Toggle Memory Advisory: Turns Empirical Memory Advisory prompt injection ON or OFF.Ctrl+R· Rescan Scorebook: Rescansknowledge/golden_tracksfor newly added.strudel.js,.js, or.mjsfiles.
Ctrl+L· Launch Local Studio: Opens the embedded Visual Studio in your browser at http://127.0.0.1:7777/studio, with automatic REPL runtime evaluation, interactive sliders, visualizers, and theme switching. PressCtrl+Enterin the browser tab to audition audio.Ctrl+O· Open on Strudel.cc: Pushes the current score directly into the full public Strudel REPL at strudel.cc.- Left/Right Arrow keys in Pane 3 · Nudge Tempo: Adjust the top-level
setcps()tempo down or up by0.02CPS (approximately 4.8 BPM) directly from the TUI. - Up/Down Arrow keys in Pane 3 · Scroll Score: Scroll through the generated Strudel code.
Ctrl+Y· Like (Endorse): Records explicit user approval for the active composition in Sonic Intelligence memory.Ctrl+N· Revise (Reject): Records explicit revision feedback for the active composition in Sonic Intelligence memory.Ctrl+S· Save & Archive: Writes the active score tomasterpiece.strudel.jsand saves a non-destructive timestamped copy toexports/.Ctrl+M· Cycle Models: Switches between all auto-discovered local Ollama models and displays the active inference profile.
MotifAI maintains strict separation between verification stages across the TUI, logs (forge_debug.log), and empirical memory[cite: 3, 4, 6, 10].
The source passed lexical delimiter, mini-notation, slider-arithmetic, and stem-usage checks in strudel_ast.rs[cite: 3, 8].
The pinned @strudel/repl@1.3.0 browser instance executed setCode() and evaluate() without throwing a syntax or evaluation error.
Passing static preflight and REPL evaluation does not automatically prove audible output[cite: 3, 6, 8, 10]. Press Ctrl+Enter in the Studio to audition playback, then use Ctrl+Y to endorse compositions you genuinely like.
Disclaimer: MotifAI is an experimental algorithmic composition studio. Musicality and synthesis complexity depend on the selected local LLM and your hardware environment.