Skip to content

🎡 Transform source code into music β€” hear the rhythm of your code. MCP Server + Web App. Built for Agents League 2026.

License

Notifications You must be signed in to change notification settings

jpablortiz96/codesonify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 CodeSonify β€” Hear Your Code

Agents League 2026 Track Built with MCP Tools License

Every line of code has a melody. CodeSonify transforms source code into real music. Functions become melodies, loops become rhythms, conditionals become chord changes, and bugs sound dissonant. Export to MIDI, sonify git diffs, and hear the evolution of your codebase β€” all integrated into GitHub Copilot via MCP.


🎬 Demo

πŸ“Ή Watch the demo video β†’

Try it yourself: Clone the repo, run npm start, and open http://localhost:3000


🌟 Features

🎡 Code β†’ Music Engine

Paste any code β€” JavaScript, TypeScript, Python, Java, C#, Go, Rust β€” and hear it as music. Each programming construct maps to a distinct musical element:

Code Structure Musical Element Why
Functions Ascending melodic phrases Functions are the building blocks β€” they create the melody
Loops Repeating rhythmic patterns Loops repeat β€” just like rhythm
Conditionals Harmonic chord changes if/else creates branching paths β€” like harmonic tension and resolution
Variables Deep bass notes Variables are the foundation β€” like bass in music
Classes Power chords Classes are structures β€” rich, layered chords
Comments Ambient pads Comments are the quiet spaces between the code
Errors Dissonant clusters Bugs should sound bad β€” because they are
Nesting depth Octave (pitch) Deeper nesting = higher pitch = more tension
Complexity Tempo (BPM) Complex code plays faster and more intensely
Language Musical key Each language has its own key signature

🎹 MIDI Export

Export any sonification as a real .mid file that opens in GarageBand, FL Studio, Ableton, Logic Pro, or any DAW. Your code becomes real, editable, shareable music.

πŸ”„ Diff Sonification

Sonify git diffs and code changes:

  • Added lines β†’ Bright, ascending melodies in major key
  • Removed lines β†’ Dark, descending bass in minor key
  • Context β†’ Soft ambient background
  • Hear a refactoring as a musical journey from tension to resolution

🎨 5 Musical Styles

Style Key Character
🎻 Classical C Major Elegant, sine/triangle waves
🎹 Electronic A Minor Driving, square/sawtooth waves
🌊 Ambient D Pentatonic Dreamy, heavy reverb
🎷 Jazz F Dorian Warm, swing feel
🎸 Rock E Blues Aggressive, distorted

πŸ”§ MCP Server β€” 5 Tools for GitHub Copilot

CodeSonify integrates directly into VS Code via MCP, giving GitHub Copilot 5 powerful tools:

# Tool What it does
1 sonify_code Transform any code into a full musical composition
2 analyze_code_structure Get code metrics: complexity, functions, nesting, loops
3 compare_code_musically Compare two code snippets by their musical output
4 sonify_git_diff Turn git diffs into music β€” hear your code reviews
5 export_midi Export code as a real MIDI file for music production

🌐 Web Application

A polished, real-time web interface featuring:

  • Code editor with syntax highlighting
  • Real-time canvas visualization with animated note particles
  • Live audio playback using Tone.js Web Audio synthesis
  • Stats dashboard showing tempo, key, complexity, notes, duration, tracks
  • Track breakdown with per-instrument volume bars
  • Musical interpretation β€” human-readable description of what the music represents
  • Diff Mode β€” compare old vs new code versions visually and musically
  • MIDI download β€” one-click export to .mid file

πŸš€ Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/YOUR_USERNAME/codesonify.git
cd codesonify

# Install dependencies
npm install

# Start the web application
npm start

Open http://localhost:3000 in your browser. Paste code, pick a style, and click Sonify Code. 🎡

Using the MCP Server with GitHub Copilot

  1. Open the project folder in VS Code
  2. Open .vscode/mcp.json β€” click the "Start" button that appears
  3. Open Copilot Chat (Ctrl+Shift+I) β†’ switch to Agent Mode
  4. Try these prompts:
Sonify this code: function fibonacci(n) { if (n <= 1) return n; return fibonacci(n-1) + fibonacci(n-2); }
Analyze the code structure of my current file
Export this as MIDI: const greet = (name) => console.log(`Hello ${name}`)
Sonify the diff between these: 
Old: "function add(a,b) { return a+b; }"  
New: "const add = (a: number, b: number): number => a + b;"

πŸ“ Project Structure

codesonify/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/                  # Core analysis and music engine
β”‚   β”‚   β”œβ”€β”€ types.ts           # TypeScript type definitions (40+ types)
β”‚   β”‚   β”œβ”€β”€ parser.ts          # Code structure analyzer & tokenizer
β”‚   β”‚   β”œβ”€β”€ mapper.ts          # Code-to-music mapping engine (8 scales, 5 styles)
β”‚   β”‚   β”œβ”€β”€ composer.ts        # Composition orchestrator
β”‚   β”‚   β”œβ”€β”€ midi.ts            # Pure TypeScript MIDI file generator (zero dependencies)
β”‚   β”‚   β”œβ”€β”€ diff.ts            # Git diff parser & sonification engine
β”‚   β”‚   └── index.ts           # Module exports
β”‚   β”œβ”€β”€ mcp/                   # MCP Server for VS Code / GitHub Copilot
β”‚   β”‚   └── index.ts           # MCP server with 5 tools
β”‚   └── web/                   # Web application
β”‚       β”œβ”€β”€ server.ts          # Express API server (5 endpoints)
β”‚       └── public/
β”‚           └── index.html     # Frontend (Tone.js + Canvas visualization)
β”œβ”€β”€ docs/
β”‚   └── copilot-usage/         # Screenshots of GitHub Copilot usage
β”œβ”€β”€ .vscode/
β”‚   └── mcp.json               # MCP server configuration for VS Code
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ LICENSE
└── README.md

πŸ€– GitHub Copilot Usage

GitHub Copilot was instrumental throughout the entire development of CodeSonify. Here's how AI-assisted development shaped this project:

🧠 Architecture & Design (Copilot Chat)

  • Brainstormed the mapping between programming constructs and musical elements
  • Designed the TypeScript type system with 40+ types for code analysis and music composition
  • Explored which musical scales best represent each programming language
  • Debugged audio timing issues with Tone.js Web Audio API

⚑ Code Acceleration (Copilot Suggestions)

  • Auto-completed musical scale definitions (major, minor, pentatonic, blues, dorian, mixolydian, lydian, chromatic)
  • Generated Express route handlers with input validation
  • Suggested the canvas visualization algorithm for animated note particles
  • Completed the MIDI binary format implementation (variable-length quantities, track chunks)

🎨 Creative Exploration

  • Used Copilot to explore different approaches to code complexity scoring
  • Generated example code snippets that showcase diverse musical outputs
  • Helped design the diff-to-music mapping logic (ascending = additions, descending = deletions)

πŸ”§ MCP Server Development

  • Copilot Chat helped structure the MCP tool definitions with proper Zod schemas
  • Generated the formatted markdown output for each tool response
  • Assisted with the comparison table formatting in compare_code_musically

πŸ“Έ Screenshots of these interactions are in docs/copilot-usage/


πŸ”Œ API Reference

POST /api/sonify

Transform code into music.

Request:

{
  "code": "function hello() { console.log('world'); }",
  "language": "javascript",
  "style": "classical"
}

Response: Full composition with tracks, notes, analysis, and visualization data.

POST /api/export-midi

Export code as a downloadable MIDI file.

Request: Same as /api/sonify

Response: Binary .mid file download.

POST /api/sonify-diff

Sonify code changes.

Request:

{
  "old_code": "function add(a,b) { return a+b; }",
  "new_code": "const add = (a: number, b: number): number => a + b;",
  "style": "electronic"
}

GET /api/examples

Get example code snippets for demo.

GET /api/health

Health check.


πŸ† Evaluation Criteria Alignment

Criteria Weight How CodeSonify Delivers
Accuracy & Relevance 20% Fully meets Creative Apps track requirements. Extensive GitHub Copilot usage documented. MCP server with 5 tools integrated into VS Code.
Reasoning & Multi-step Thinking 20% 7-step pipeline: Code β†’ Tokenize β†’ Analyze β†’ Map β†’ Compose β†’ Visualize β†’ Play. Diff analysis adds comparison reasoning. MIDI export adds format transformation.
Creativity & Originality 15% First-of-its-kind code sonification tool. Unique concept bridging programming and music. Diff sonification has never been done. MIDI export makes it tangible.
User Experience & Presentation 15% Polished web UI with real-time visualization, 5 musical styles, Diff Mode, MIDI download, example code, animated particles, playback controls.
Reliability & Safety 20% TypeScript strict mode throughout, input validation on all endpoints, error handling with user-friendly messages, no secrets/PII, public repo, MIT license.
Community Vote 10% Viral concept β€” "hear your code" is immediately shareable. Fun to demo. Everyone can try it. MIDI export makes it tangible and social.

πŸ› οΈ Technologies

Technology Purpose
TypeScript Type-safe code throughout (strict mode)
MCP SDK Model Context Protocol for VS Code/Copilot integration
Express 5 Web server and REST API
Tone.js Web Audio synthesis and real-time playback
Canvas API Animated note particle visualization
Zod Runtime input validation for MCP tools
GitHub Copilot AI-assisted development throughout

🎯 Use Cases

  1. Code Review β€” Sonify a pull request diff and hear if the changes feel harmonious or chaotic
  2. Education β€” Help students understand code structure through musical metaphor
  3. Accessibility β€” Provide auditory feedback for visually impaired developers
  4. Team Building β€” Turn your team's code into a collaborative soundtrack
  5. Art β€” Generate music from open-source projects and create "code albums"
  6. Quality Monitoring β€” Complexity score as tempo: if your code sounds like speed metal, maybe refactor

πŸ“ License

MIT License β€” free to use, modify, and distribute.


πŸ™ Acknowledgments


🎡 Where every line of code has a melody 🎡

About

🎡 Transform source code into music β€” hear the rhythm of your code. MCP Server + Web App. Built for Agents League 2026.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published